Run Included Tests with App Center
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.
Prerequisite
- Follow the getting started tutorial to set up the sample app.
Install App Center Command Line Interface
Install Node.js version 6.3 or later.
Open the terminal and run the command below to install the App Center CLI:
npm install -g appcenter-cli
Run the command below and follow the directions to log in to App Center:
appcenter login
Build the project and test APK files
Open terminal and go to the project directory.
Run each of the following commands:
./gradlew assembleDebug ./gradlew assembleDebugAndroidTest
Prepare to run tests in App Center
Go to the Test service in App Center.
Click on Start testing your app.
Select the first device, the Google Pixel XL, and press Select one device at the bottom.
Choose Espresso as the Test framework.
Click Next.
Run the tests
In the Submit step, copy the custom command under Running tests.
Paste it into terminal while in the project directory.
Note
--app-path
should point to a mobile app apk and --build-dir
should point to where the test apk is located at.
Navigate into sampleapp-android/app/build/outputs/apk.
Copy the pathname and replace the placeholder text
pathToEspressoBuildFolder
in the custom command with the pathname text.Copy the pathname to app-debug-androidTest.apk and replace the placeholder text
pathToFile.apk
in the custom command with the pathname text.Run the command. You'll see the tests begin to run.
In App Center, click Done to close the panel.