Andrew Thomas




Blog Post

Visual Studio Team Services, .Net Core, Build and XUnit

Oct 17, 2019 Azure DevOps

Recently I had completed a project in the new .Net Core and I wanted to build it through my Team Services account. Setting up the build is super easy now with the UI, and in no time I had automatic builds setup on check-in. What I noticed though was that none of my tests were being found and so were not running.

As a bit of background I use XUnit for testing, originally because this was the only framework that supported the new .xproj format, even mstest didn’t seem to (bleeding edge technology incompatibility seems on the rise with Visual Studio at the momement). Once I started using it though I really liked it, and agree with their philosophy on testing and why it came about. You can read more about that here.

As always I did a quick google and search on Stack Overflow but didn’t come up with anything useful — all I could find was adding a command line build step that would execute against the DLL’s, and this meant adding a runner package to each unit test. The output would also not be useful for builds and not give the rich UI you get from mstest. Ugh. I hoped this wasn’t it.

Anyway after more researching I find out that the new testing framework can actually read everything it needs to from the project.json file — provided you have the “testRunner” parameter specified in the JSON file. I wasn’t sure if this would just work for mstest, but I opted to give it a go, and it did! Here are the settings I used:

Test Assembly Setup

And if you look at the output you can see correctly segmented tests and you can click through to view them:

Test Output

Hopefully this helps others save some time.