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.


Leave a Reply

Your e-mail address will not be published. Required fields are marked *