This guide describes how to prepare an XCTest for testing in Firebase Test Lab.
Step 1: Configure your project's Derived Data location
Xcode places compiled iOS artifacts, including any tests you build, in a Derived Data directory. It is possible to keep the default location for that directory, if you'd like, but it's often helpful to choose a more easily-accessible place for the files, especially if you're going to be running tests with Test Lab often:
- Open your project in Xcode.
- In the macOS menu bar, select File > Project Settings...
- Change the Derived Data dropdown from Default Location to Custom Location.
- In the field below the dropdown, select a location for Xcode to output your tests to.
Step 2: Build a generic test file
Test Lab runs unit tests and UI tests using the XCTest framework. To run your app's XCTests on Test Lab devices, build it for testing on a Generic iOS Device:
- From the device dropdown at the top of your Xcode workspace window, select Generic iOS Device.
- In the macOS menu bar, select Product > Build For > Testing.
Step 3: Package your app for uploading
Finally, build and package your test for upload to Test Lab by compressing
the test files you built into a
To build your XCTest, use the following command in a terminal:
xcodebuild -project PATH/TO/YOUR_WORKSPACE.xcodeproj \ -scheme YOUR_SCHEME \ -derivedDataPath FOLDER_WITH_TEST_OUTPUT \ -sdk iphoneos build-for-testing
xcodebuild -workspace PATH/TO/YOUR_WORKSPACE.xcworkspace \ -scheme YOUR_SCHEME \ -derivedDataPath FOLDER_WITH_TEST_OUTPUT \ -sdk iphoneos build-for-testing
After your test successfully builds, zip it for upload to Test Lab:
cd FOLDER_WITH_TEST_OUTPUT/Build/Products : \ zip -r MyTests.zip Debug-iphoneos YOUR_SCHEME_iphoneosDEPLOYMENT_TARGET-arm64.xctestrun
You can also package up your test by compressing the test files manually:
Open Finder and navigate to the directory you designated for Derived Data output.
Open the folder you selected for your project, then open the
Select the folders
PROJECT_NAME_iphoneosDEVELOPMENT_TARGETarm64.xctestrunand then compress them.