Subscribe Now: Feed Icon

Wednesday, June 8, 2011

TeamCity: Running Unit Tests

Summary: Running Unit Tests and Code Coverage using TeamCity

This is the third post in my TeamCity series, the first post is TeamCity: Easy Continuous Integration and the second is TeamCity: Building the Solution

After the last post which was too long this should be quite short. Remember in the last post I showed you the full list of build runners, then one of the build runners was MsTests (and another was NUnit).

So from the project view click on Edit Configuration Settings (in the upper right corner):


Now on the right click on 3 Build Step:


Now click on Add build step, in Runner type choose MsTest:


Its optional but add a name to the step, in path to MSTest.exe either click on your version of VS (2010 = 10, 2005 = 9 …) or leave blank.

Testing with NUnit is pretty similar:


The list of assemblies here and MsTest is of the dlls of the test projects from VCS root (from the setting of TFS Source Control). Just like in the previous post with the solution file.


On the bottom in .NET Coverage tool chose JetBrains dotCover, this uses TeamCity’s dotCover which gives pretty good results.

Click on Save. And that’s it.



Looking into the build run:


Looking at the full report:


When reaching the class being tested:


We can see that not all of the method is tested. In actuality I believe that code is inaccessible (can an enum value be empty so that it’s ToString will return an empty string?) but it’s good for the demonstration.

You can view the class here, and it’s tests here.