I’ve recently started trying to get my head around unit testing (I probably should have learnt this a while ago) and part of this has involved trying to figure out the best way to integrate them with Azure DevOps.

In my case I wanted to have a pipeline which built the code in my repository and ran tests on it using xUnit and then if successful triggered a release which deploys the published artifact to an Azure Web App.

The first step in building my pipeline was to use the visual designer rather than YAML as although I’m sure YAML is more powerful it wasn’t as easy to get started with.

Within the visual designer I based my template on the ASP.NET template, this contains all the steps needed to build, test and publish my project, the only change required was to tell the “Test Assemblies” step where to find the testing dlls for my project.

**\bin\$(BuildConfiguration)\**\*test*.dll
!**\obj\**
!**\xunit.runner.visualstudio.testadapter.dll
!**\xunit.runner.visualstudio.dotnetcore.testadapter.dll

Once this has been setup a build can be queued and upon completion the test results are visible in the build tests summary.

I also installed the Analytics extension in my DevOps instance to give me an overall aggregation of the test results in addition to the build level view available by default.

I then created a release triggered by a successful build to deploy the published artifact to an Azure Web App, if any of the tests in the build were unsuccessful then the build will fail and the release won’t be deployed.


Junsoo Ha · 15th August 2019 at 11:16 am

Argh… Thank you SO MUCH. I spent a good week spending on making my first yaml to work, and spend few hours every time I create CI build task. I wonder why there wasn’t a visual tool like the one in the release pipeline, but there it is. OMG. I hate you Azure Devops team.

Thank you so much for your post and the tip. I also wanted to use xunit in devops and google brins me here.

Leave a Reply

Your email address will not be published. Required fields are marked *