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.


4 Comments

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.

Karthik · 14th February 2020 at 2:13 pm

Thanks for your post.

Tania Zaman · 16th February 2020 at 7:16 pm

Starting test execution, please wait…
Information: [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (32-bit Universal Windows)

Information: [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (32-bit Desktop .NET 4.0.30319.42000)

My tests are not getting discovered on Azure DevOps. They are working fine on my local developer machine. Here is the error message –

Warning: [xUnit.net 00:00:00.22] Skipping: .Tests (could not find dependent assembly ‘System.Runtime, Version=4.1.2’)

Warning: No test is available in Tests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.

    Shinigami · 17th February 2020 at 9:51 am

    Hm, hard to tell why this isn’t working for you. It’s possible that your tests are built for 64-bit and it’s trying to run them as 32-bit in DevOps so you’ll need to change the default processor architecture of your tests.

Leave a Reply

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