AWS Device Farm
Developer Guide (API Version 2015-06-23)

Working with XCTest for iOS and AWS Device Farm

With Device Farm, you can use the XCTest framework to test your app on real devices. For more information about XCTest, see Testing Basics in Testing with Xcode.

To run a test, you create the packages for your test run, and you upload these packages to Device Farm.

Creating the Packages for Your XCTest Run

To test your app by using the XCTest framework, Device Farm requires the following:

  • Your app package as a .ipa file.

  • Your XCTest package as a .zip file.

You create these packages by using the build output that Xcode generates. Complete the following steps to create the packages so that you can upload them to Device Farm.

To generate the build output for your app

  1. Open your app project in Xcode.

  2. In the scheme dropdown menu in the Xcode toolbar, choose Generic iOS Device as the destination.

  3. In the Product menu, choose Build For, and then choose Testing.

To create the app package

  1. In the project navigator in Xcode, under Products, open the contextual menu for the file named app-project-name.app. Then, choose Show in Finder. Finder opens a folder named Debug-iphoneos, which contains the output that Xcode generated for your test build. This folder includes your .app file.

  2. In Finder, create a new folder, and name it Payload.

  3. Copy the app-project-name.app file, and paste it in the Payload folder.

  4. Open the contextual menu for the Payload folder and choose Compress "Payload". A file named Payload.zip is created.

  5. Change the file name and extension of Payload.zip to app-project-name.ipa.

    In a later step, you provide this file to Device Farm. To make the file easier to find, you might want to move it to another location, such as your desktop.

  6. Optionally, you can delete the Payload folder and the .app file in it.

To create the XCTest package

  1. In Finder, in the Debug-iphoneos directory, open the contextual menu for the app-project-name.app file. Then, choose Show Package Contents.

  2. In the package contents, open the Plugins folder. This folder contains a file named app-project-name.xctest.

  3. Open the contextual menu for this file and choose Compress "app-project-name.xctest". A file named app-project-name.xctest.zip is created.

    In a later step, you provide this file to Device Farm. To make the file easier to find, you might want to move it to another location, such as your desktop.

Uploading the Packages for Your XCTest Run to Device Farm

Use the Device Farm console to upload the packages for your test.

  1. Sign in to the Device Farm console at https://console.aws.amazon.com/devicefarm.

  2. If you don't have a project already, create one. For the steps to create a project, see Create a Project in AWS Device Farm.

    Otherwise, choose the project that you want to use to run the test.

  3. Choose Create a new run.

  4. On the Choose your application page, choose the option to Test a native application on Android or iOS devices.

  5. Choose Upload.

  6. Browse to the .ipa file for your app and upload it.

    Note

    Your .ipa package must be built for testing.

  7. After the upload completes, choose Next step.

  8. On the Configure your test page, for Test, choose XCTest. Then, choose Upload.

  9. Browse to the .zip file that contains the XCTest package for your app and upload it.

  10. After the upload completes, choose Next step.

  11. Complete the remaining steps in the project creation process. You will select the devices that you want to test on and specify the device state.

  12. After you configure your run, on the Create a new run page, choose Confirm and start run.

    Device Farm runs your test and shows the results in the console.