Skip to content
No description, website, or topics provided.
Branch: master
Clone or download

AWS Device Farm Sample App for iOS

This is a sample native iOS app that contains many of the stock iOS components and elements. It also contains multiple Calabash tests to get you started. You can also use this app with the AWS Device Farm Built-in Fuzz Test.

You can use this app and example test suite as a reference for your own Device Farm tests.


All of the views are programatically created within the app. Storyboard or XIB files are not used. This is to prevent merge conflicts in the future.

Explicit delays are occasionally added to the tests to allow the page to fully render, they are commented as such in the code.

Getting Started

In order to run this app within Device Farm you will need to create a local copy of this repository and build the application from source.

Building Project with Xcode

  1. Select the Calabash target (if built with Calabash) and select an iOS Device
  2. Use the Product/Build for Running option

Packing and Creating IPA

  1. Go into your build directory: ~/Library/Developer/Xcode/DerivedData/ProjectName/Build/Products/Debug-iphoneos
  2. Create a new directory named "Payload"
  3. Move the folder into the "Payload" folder
  4. Zip the "Payload" folder and give it a .ipa extension

Testing on Device Farm

Follow the steps in the official AWS Device Farm documentation for:

  1. Built-in Fuzz Testing
  2. Calabash Testing

Examples of Specific Scenarios

Component App Implementation
Alerts: Modal View, Alerts, Pop Overs (only works on iPads) source code - Calabash Test
Static Page source code - Calabash Test
Login Page source code - Calabash Test
Navigation Controllers source code - Calabash Test
Expected Crash source code
Web View source code - Calabash Test

Examples of Native Features

Feature App Implementation
Camera source code
Image Gallery source code
Scroll View source code
Out of View Content source code
Video source code
Table of Elements source code

Examples of Inputs

Component App Implementation
DatePicker source code
ContactAddButton source code
TextView source code
Labels source code
Text Input source code
Gestures Input source code
Refresh Control source code
Button source code
Data Picker source code
Switch View source code

Examples of Navigation

Component App Implementation
Tab Bar source code
Page Viewer source code

Using XCUI Recorder


  1. Xcode 9 or above
  2. iOS simulator downloaded or a physical iOS device.


  1. Download the AWS Device Farm iOS sample app.
  2. Open the project in Xcode.
  3. We will generate tests XCUI using a new test target.
  • Select File —> New —> Target —> iOS UI Testing Bundle.
  • Click Next.
  • Enter a Product Name
    For e.g. AWSDeviceFarmiOSReferenceAppUITests_Mock
  • If you have a apple developer account you can choose that for the Team option.
  • Choose Language as Swift.
  • Click Finish.
  1. In your project navigator you should now see the new target swift files generated. Open AWSDeviceFarmiOSReferenceAppUITests_Mock.swift.
  2. The file will have setUp(), tearDown() and a testExample() function. testExample() is the function where our test code generated through XCUI test recorder will live. Click inside the scope of function testExample().
  3. Select a target device for the recording. Click on the red record button present in the Debug bar as shown below. This will open up the selected simulator for you to record your UI interactions.

  1. When the app opens up on the simulator, inside the app click on More —> Alerts —> Modal --> OK

  2. Go to Xcode and press the record button again to stop recording the test. We now have the test code generated to test Alert section of the sample app.

    We will add an XCAssert after the recording is complete to check if the modal view is present. This can done using the code snippet :

XCTAssertNotNil(app.staticTexts["This is a modal view"])
  1. The project has existing XCUI tests which we do not want to run. We will disable the existing tests and only run our generated tests. Go to Product —> Scheme —>Edit Scheme. Select Build on left hand side. Uncheck all existing test targets except AWSDeviceFarmiOSReferenceApp and your generated test target AWSDeviceFarmiOSReferenceAppUITests_Mock
  2. For specifying which tests to build select Test on the left side. Click on ‘+’ . Choose only your test target. Click Add. Click Close in the main window.
  3. To build the tests for simulator go to Product —> Build for Testing.
    Note: If you want to run on Device Farm you should build and run your tests against a real physical device. Tests build for simulator will not run on real devices. For the purpose of the instructions here we are going to consider simulator.
  4. To run the tests go to Product —> Test. This will open up the simulator and run the tests.
  5. We want to package and upload these tests to Device Farm to test it against a number of devices.
    To package the tests go to your Project explorer on the left hand side. Right click on AWSDeviceFarmiOSReferenceApp under Products folder —> Show in Finder. This will take to the location of your app and tests build output. Look for the runner app of your tests: AWSDeviceFarmiOSReferenceAppUITests_Mock-Runner. Create a folder named “Payload” case-sensitive anywhere in your file system. Copy the tests runner app inside Payload. Right click on Payload —> Compress Payload. Rename the extensions of the compressed zip file to .ipa. When asked if you want to keep .ipa option choose yes. This is your test IPA that can be uploaded to AWS Device Farm.
  6. You can build an IPA of the app using your developer account or a pre-built version of the app and tests can be found here.
You can’t perform that action at this time.