XCTest/XCUITest
Help Documents menu

XCTest/XCUITest

Updated on: 2022-01-26 14:54

Introduction to XCTest/XCUITest

XCTest/XCUITest is the testing framework supplied by Apple. You can create unit tests and UI tests in your Xcode project. Please refer to Apple Developer Official Doc for detailed introduction.

Running XCTest/XCUITest on WeTest Cloud Servers

WeTest launches your uploaded XCTest packages on target mobile devices in parallel. You may specify different versions to run your tests.

Xcode versions:

  1. Xcode 11.6 and Xcode 12.3 are provided for devices with iOS from 11.0 to 14.8
  2. Xcode 11.6, Xcode 12.3, and Xcode 13.0 are provided for devices with iOS 15 or above.

Please follow the steps below to prepare your XCTest/XCUITest script(.zip file) for uploading to WeTest and start your test!

Prepare your XCTest/XCUITest zip package

1. Build your project

Option1

Please use following command line to build your project.

xcodebuild -project YOUR_PROJECT.xcodeproj \
-scheme YOUR_SCHEME \
-derivedDataPath DERIVED_DATA_OUTPUTPATH \
-sdk iphoneos build-for-testing

Option2:

In Xcode, Click Product -> Buld For -> Testing to build your project.

2. Create a script package

WeTest accepts a zip file as the script package. Please zip all test script files(.xctestrun files and Debug-iphoneos directory) and/or a config file (xctest_config.json) into one .zip file.

cd DerivedData/yourProject/Build/Products 
zip -r TestsOnWeTest.zip Debug-iphoneos   your_xctestrun_file.xctestrun

Sample zip contents(XCTest/XCUITest)

Debug-iphoneos
<your_project>.xctestrun
[optional]xctest_config.json

3. [Optional] WeTest XCTest/XCUITest Configuration File

File name: xctest_config.json with following file content.

{
   "xcodeVersion":"12.3",
   "disableResign": false
}

*You might set “11.6” or “12.3” as the value of “xcodeVersion” when device OS version less than or equals to iOS 14.8.

*You might set “13.0” as the value of “xcodeVersion” when device OS version large than or equals to iOS 15.0

*The default value of “disableResign” is false, namely, WeTest would resign your .app bundles before tests.

Please add the WeTest XCTest/XCUITest configuration file (xctest_config.json) into the test script package TestsOnWeTest.zip created in the previous step.
The WeTest XCTest configuration file is optional. If there is no xctest_config.json in the test script package, WeTest would use default settings to run the tests.

zip  TestsOnWeTest.zip xctest_config.json

Sample Script running on WeTest

iOS XCTest/XCUITest Test Script

Sample Script - iOS XCTest/XCUITest