Create, Upload and Run Tests in VSAC
In this lab we will Create and configure a new Test run in Visual Studio App Center (VSAC), prepare and then upload the Tests, Run and then review them.
DevOps MPP Course Source
- This lab is used in course DevOps200.8x: DevOps for Mobile Apps - Module 3.
- Complete the earlier Mobile VSAC lab Getting Started in Visual Studio App Center
- Add Getting Started Android app to Visual Studio App Center
- Build the sample app Getting Started for Android
- Sign the app with an Ad-Hoc keystore
- Store the
GettingStarted.apkin a folder on your workstation, referred to as
- Create and configure new test run
- Install App Center CLI
- Prepare Tests for Upload
- Upload and Run Tests
- Review Tests
Estimated Lab Time:
- approx. 30 minutes
Task1: Create and Configure Test Run
Select the Getting Started app for Android, which uses Xamarin.UITest.
Under Build > New Test Runs, click the New Test Run button.
Configure your test run by using the Test Run Wizard. Name the test run “First Tests”. Pick the Test Series default master. Choose a system language of English (United States), and the test framework Xamarin.UITest.
Select five devices of your choosing to run your tests on.
Copy the entire
appcenter test runcommand for later use.
Task 2: Install App Center CLI
To submit tests, you must install App Center Command Line Interface (CLI) on your development computer. The CLI runs on Node.js, so it can be installed on a Windows or macOS machine. The installation requires two steps:
In your browser, navigate to the Node.js download page and download and install Node.js. The LTS version should suffice.
Invoke a command prompt and change the directory to the Node.js installation directory, typically C:\Program Files\nodejs on Windows. Install the appcenter-cli NPM package by using this command:
npm install -g appcenter-cli
Task 3: Prepare Tests for Upload
Prepare the Getting Started Xamarin.Android app and UITest for submission to App Center Test. The Getting Started app already has the INTERNET permission granted in
In the Getting Started app, confirm that the Shared Mono Runtime is disabled. The Shared Mono Runtime will prevent UITests from running in App Center Test.
On Visual Studio 2017, open project properties and select the Android Options tab. In the Packaging Properties section, uncheck the checkbox for the Shared Mono Runtime.
On Visual Studio for Mac, look in the Project Options, under Build > Android In the Packaging and Deployment section of the General tab, uncheck the checkbox for the Shared Mono Runtime.
Task 4: Upload and Run Tests
After installing the App Center CLI, log in to App Center and upload your tests. Follow these steps:
Open a command prompt and navigate to the NuGet /package directory of your app solution.
Log in to App Center by using the command
appcenter login. You’ll be redirected to your browser where App Center will provide you with an authentication code. Copy that token and paste it back into the the command prompt window to authenticate.
Upload your tests by using the
appcenter test runcommand you copied from the final page in the New Test Wizard in App Center Test when you created a new test run. Your command will look something like this, which is for Xamarin.UITest:
appcenter test run uitest --app "Getting-Started" --devices devicesid --app-path pathToFile.apk --test-series "First Tests" --locale "en_US" --build-dir pathToUITestBuildDir
- Populate the placeholder fields with your real values in parameters, including devices, app-path, and build-dir. Here are the main parameters in the
appcenter test runcall:
- app – Name of the app in VSAC
- app-path - Path to the app to be tested, ex. .apk, .ipa , ex. “\Development\GettingStarted\GettingStarted.Android\bin\Release\GettingStarted.Android.apk”
- devices – ID or name of device set in VSAC to run tests on
- test-series - Name of the test series in VSAC that this test run will belong to
- build-dir – Directory path of your test assembly, ex. “\Development\GettingStarted\UITests\bin\Release”
Here is an example command:
appcenter test run uitest --app "Getting-Started" --devices 4c93991 --app-path "\Development\GettingStarted\GettingStarted.Android\bin\Release\GettingStarted.Android.apk" --test-series "First Tests" --locale "en_US" --build-dir "\Development\GettingStarted\UITests\bin\Release"
When you provide the correct parameters and your tests are coded properly then the
appcenter test run command will upload your tests to App Center Test and run them immediately. The command window will show you the list of test devices and high level results for each device. If you experience issues, follow the error messages and ensure that your artifacts are in the specified folders.
Task 5: Review Tests
After your tests have completed running by using the
appcenter test run command, you can view the results online in App Center Test.
Click on the VSAC menu Tests>Test Runs and choose the test run you’d like to review. If you’re using test series, flip between test series by using the Test Series button at the top of the screen. Review the test report for that test run.
Drill down into specific tests for device screenshots.
Click on a device for a large screenshot and additional details such as hardware usage and timings.
Click the Details button to see the device-specific specifications. Review and exit details.
Click the Logs button to review the device logs, test logs, and a stack trace.
In this lab you completed the following tasks
- Created and configured new test run
- Installed App Center CLI
- Prepared Tests for Upload
- Uploaded and Run Tests
- Reviewed Tests