Edit

Share via


Test - Sample Swift iOS App and Tutorials

Important

Visual Studio App Center is scheduled for retirement on March 31, 2025. While you can continue to use Visual Studio App Center until it is fully retired, there are several recommended alternatives that you may consider migrating to.

Learn more about support timelines and alternatives.

XCUITests are included with the sample app. In this tutorial, you'll learn to run the UI tests using App Center.

First, follow the getting started tutorial to set up the sample app.

Prerequisites

  • Provisioning Profile and Certificate. Go to the Apple Developer Documentation to learn about creating an App ID to codesign the sample iOS app with.

Install App Center Command Line Interface

  1. Install Node.js version 6.3 or later.

  2. Open the terminal and run the command below to install the App Center CLI:

    npm install -g appcenter-cli
    
  3. Run the command below and follow the directions to log in to App Center:

    appcenter login
    

Make the test folder

  1. Open a terminal and go to the project directory.

  2. Run the command below to remove the derivedDataPath if it exists:

    rm -rf ddp
    
  3. Run the command below to make the build folder for tests:

    xcrun xcodebuild build-for-testing -configuration Debug -workspace sampleapp-ios-swift.xcworkspace -sdk iphoneos -scheme sampleapp-ios-swift -derivedDataPath ddp
    

Prepare to run tests in App Center

  1. Go to the Test service in App Center.

  2. Click on Start testing your app.

  3. Select the first device, the Apple iPhone 7 Plus, and press Select one device at the bottom.

  4. Choose XCUITest as the Test framework.

  5. Click Next.

Run the tests

  1. Copy the custom command under Running tests.

  2. Paste it into the terminal while in the project directory.

  3. Replace pathToXCUItestBuildFolder with the text below:

    ddp/Build/Products/Debug-iphoneos
    
  4. Run the command. You'll see the tests begin to run.

  5. In App Center, click Done to close the panel.