Run your first test

XCUITest is a mobile automation framework from Apple that helps you write UI tests for your iOS applications. BrowserStack App Automate supports XCUI testing on a wide range of real iOS devices. This guide will help you run your first XCUI test on BrowserStack.

1. Setup

  1. You will need a BrowserStack username and access-key. To obtain your access credentials, sign up for a free plan or purchase a plan.

  2. XCUI tests are built into a separate zip file. Hence, you will need access to both the app (.ipa file) as well as XCUI test-suite (separate .zip file).

Note: If you do not have .ipa files and are looking to simply try App Automate, you can download our Sample app and Sample test-suite. Alternatively, refer to our XCUI sample GitHub repository.

2. Upload your app

Upload your iOS app (.ipa file) to BrowserStack servers using our REST API. Here is an example cURL request to upload the app :

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/app/file/app-debug.ipa"

A sample response for the above request is shown below:

{
    "app_url":"bs://j3c874f21852ba57957a3fdc33f47514288c4ba4"
}

Note the value of app_url returned in the response to above REST API request. This will be used later to specify the application under test for your Espresso test execution.

Note: App upload will take a few seconds to about a minute depending on the size of your app. Do not interrupt the curl command until you get the response back.

3. Upload your test-suite

Upload your XCUI test-suite (.zip file) to BrowserStack servers using our REST API. Here is an example cURL request to upload the test-suite :

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/xcuitest/test-suite" \
-F "file=@/path/to/app/file/Application-debug-test.zip"

A sample response for the above request is shown below:

{
    "test_url":"bs://f7c874f21852ba57957a3fdc33f47514288c4ba4"
}

Note the value of test_url returned in the response to above REST API request. This will be used later to specify the test-suite containing XCUI test cases for your test execution.

Note: If you do not have a .zip file for your test-suite, follow step by step instructions in our Build and export test-suite guide to generate the zip file.

4. Execute XCUI tests

Once the app and test-suite are uploaded to BrowserStack servers, you are ready to run your first XCUI test on BrowserStack. Use the REST API to start the test execution as shown in the example cURL request below :

Select device
iPhone 11
This device is not available in the free plan. Please upgrade to paid plan.

Look for the icon to select a real device.

 

An example response to the above request is shown below. Note that the build_id is used to uniquely identify your test execution.

{
    "message":"Success",
    "build_id":"4d2b4deb810af077d5aed98f479bfdd2e64f36c3"
}

5. Viewing test results

Once you start an XCUI test-suite execution using REST API, you will be able to access the test execution results on the App Automate dashboard as well as using our REST API. You can access overall summary of your test execution and also check the result and debugging logs for every test case in the XCUI test-suite.

We're sorry to hear that. Please share your feedback so we can do better






Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback