Today I decided to migrate from Xamarin Test Cloud to App Center Test. My end goal is to incorporate the test runs in my VSTS release. However, I decided to first follow the documentation which describes how to run tests using the App Center CLI.
The installation of the CLI is very easy:
npm install -g appcenter-cli
With the CLI in place I needed to create a test run. I used an existing app that was automatically migrated to App Center from HockeyApp. From the app page I clicked on Test and created a new test run. Once I completed the wizard I was provided a template for the command line to run.
The first item I needed was the apk file I wanted to test. I opened Visual Studio and I built my project. However, when I navigated to the bin/debug folder I did not find the apk file. After some research I learned that I had to first archive the project and from there I could create the apk file.
Creating the apk was not very intuitive. Make sure you have your keystore information ready to create the apk. For this to work you need to have the Release configuration selected. Then right-click on your project and select Archive. Once the archive is created click the Distribute… button.
Follow the direction to import your keystore and produce the apk.
Now that you have an apk you can now complete the template command line and execute it. If all goes well your apk and test project will be uploaded to App Center Test and you tests executed. However, if you are like me you will get an error stating that Android SDK not found. This is very confusing because I just built the apk on this machine. How could that be possible if I was missing the SDK? Well the SDK was installed with Visual Studio but the ANDROID_HOME environment variable was not set.
To set the ANDROID_HOME environment variable I first had to find out where it was installed. To do this I searched for Android in the Options dialog of Visual Studio.
Then I created a new environment variable named ANDROID_HOME using the value from Android SDK Location. I also added %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools to the PATH environment variable for my system.
With all this in place I repeated my command line and my test were executed.