Table Of Contents
- Introduction
- Notable Files
- Getting Started On Local Machine
- Getting Started On Azure DevOps
- Explanation Of The Journey: Deadends, Pitfalls, Solutions
- Must Use MacOS Agent
- Fresh Autogenerated Pipeline
- General Pipeline YAML Advice
- Give Each Build An Increasing Android App Version
- How To Choose The Version
- Build The APK File
- Sign The APK File
- Publish The APK Files As Build Artifacts
- Build And Run Unit Tests
- Run App Center UI Tests
- Set Up And Start Android Emulator
- Build UI Tests
- Run UI Tests
- Publish UI Tests
- Problems Accessing Stuff
- Thanks To Those Who Helped Me
Introduction
I'm making this demo repo and writeup because it was surprisingly and frustratingly difficult to get Xamarin.UITest tests for Android to run on a Microsoft-hosted agent in an Azure DevOps pipeline. NO App Center. NO self-hosted agents. I just wanted to do everything in Azure DevOps.
So, this demo shows how to accomplish that, and some other common goals for an Azure Devops continuous integration pipeline for the Android portion of a Xamarin app...
- Each build gets its own
versionCode
andversionName
. - Build the APK.
- Sign the APK.
- Publish the APK as a pipeline artifact.
- Do unit tests (NUnit).
- Do UI tests (Xamarin.UITest), which involves several Android emulator steps.
- Publish test results.
This demo is not about getting started on unit testing or UI testing; the demo is about getting these things to work in an Azure DevOps pipeline.
You can see a successful run, a successful job overview, published artifacts, and unit+UI test results (also alernate view for unit test run and UI test run).
This repo is available as a visualstudio.com repo and a github repo. As of 2020-Dec-24, Azure DevOps offers a free tier with 30 build hours per month and 2 GiB of artifact storage. The free tier was more than enough for all the pipeline needs of this demo.
This writeup is available as a github readme, visualstudio.com readme, and blog post. The repo readmes will be kept up to date, but the blog post may not receive many updates after 2020-12-24. Readme section links are oriented for GitHub.