Created
November 19, 2024 23:41
-
-
Save Tulakshana/b73eb38c0b68746e72aa1a1356b32128 to your computer and use it in GitHub Desktop.
Script to run unit tests using xcodebuild. The simulator is configured and launched prior to test execution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "**********************************" | |
echo "* Create sim if needed *" | |
echo "**********************************" | |
test_device_id=$(xcrun simctl list devices | grep "circleci-test-device" | sed 's/ *circleci-test-device *(//' | sed 's/).*//') | |
if [ -z "$test_device_id" ]; then | |
echo "Creating test device" | |
runtime=$(xcrun simctl list runtimes iOS | sed 's/iOS //' | sort -h | tail -1 | sed 's/.* - //' | tr -d '[:space:]') | |
devicetype=$(xcrun simctl list devicetypes "iPhone " | sort | tail -1 | sed 's/.*(//' | sed 's/).*//' | tr -d '[:space:]') | |
test_device_id=$(xcrun simctl create "circleci-test-device" "$devicetype" "$runtime" | tr -d '[:space:]') | |
fi | |
echo "test_device_id: $test_device_id" | |
echo "**********************************" | |
echo "* Boot sim if needed *" | |
echo "**********************************" | |
xcrun simctl list devices "$test_device_id" | grep -q Booted | |
if [ $? -eq 1 ]; then | |
echo "Booting $test_device_id" | |
xcrun simctl boot "$test_device_id" | |
fi | |
echo "**********************************" | |
echo "* Test *" | |
echo "**********************************" | |
xcodebuild test \ | |
-quiet \ | |
-scheme "XCODE_UNIT_TEST_SCHEME" \ | |
-workspace "XCODE_WORKSPACE" \ | |
-destination "id=$test_device_id" \ | |
-jobs 1 \ | |
-parallel-testing-enabled NO \ | |
-sdk iphonesimulator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment