HowTo: TeamCity & CodeCoverage with dotCover

 

imageDuring our BizzBingo project we use NUnit and since TeamCity 6.0 is Jetbrains dotCover also directly integrated. How dis would look like you are getting to know now.

1. Step: create Build Configuration

This ScreenShot is from Nightly Build and there is nothing special in it.

image

 

2. Version Control Settings

You need to adjust it depending on your project but here is nothing special to beware on here. We take the Source over the SVN interface from Codeplex.

image

3. Now it´s getting interesting….

My “Nightly” consist of 3 Build-steps but in this Blogpost just two of them are important:

- Build the whole SLN with “Rebuild” / “Debug” (an MSBuild is also possible)

- Take the NUnit test runner and check the Code Coverage on dotCover

 

image

Take a deeper look on the second step:

NUnit Testrunner Configuration:

image

We´ve installed NUnit Version 2.5.8 and in the textbox “Run tests from” is this included:

%system.teamcity.build.checkoutDir%\Main\Source\BusinessBingo\Tests\*\bin\Debug\*Tests.dll

imageBecause we are building the whole SLN with “Debug” the results are shown in our source tree in the adequate bin folder.

With Wuildcards the runner will found our tests like for example BusinessBingo.Commandhandler.Tests.dll and run them.

If we decide to add more tests to our project they will appear automatically in the Build – “Convention over Configuration“.

Now the Unit tests run… let´s talk about dotCover.

In the newest version of TestCity 6.0 dotCover is directly integrated. That means, you don´t need to install it on the Buildserver. The configuration is quite easy:

image

With the filter you instruct dotCover which Code should be recognized for the CodeCoverage during UnitTesting.

+:BusinessBingo.*
-:BusinessBingo.*Test*

Important: don´t declare “.dll” here just the name. With “+” you say: search assemblies with this name (also Wildcars) and “-”means that there are no CodeCoverage.

Little hint: If you do everything right but no report will be generated take a look into the BuildLog. At the first try I got this error:

Solution:

Failed to read source file 'C:\TeamCity\buildAgent\temp\buildTmp\dotcover8583844779204955574.xml'. Could not find a part of the path 'C:\Windows\system32\config\systemprofile\AppData\Local\Temp\4q-kqg6z.tmp'.

Create the searched “Temp” folder in “C:\Windows\system32\config\systemprofile\AppData\Local”

Normally it doesn´t exist and because of this the error appeared. After this it works.

What do we have now?

Nice unit-tests which will be done by the Buildserver:

image

Code Coverage for the Assemblies:

image

Here you can see what will run or not beside of the .cs file:

image

And here we have a nice little overview:

image

Useful and easy and it doesn´t take a lot of time.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

About the author

Written by Code Inside Team

Learn more about our team.

One Response

Comment on this post

Recent Posts

  • Automated Security Analyser for ASP.NET websites

    Evil Hackers are lurking everywhere and many Web-applications are delicately and share “too much” with the attacker. A quick (first!) overview offers the Tool “ASafaWeb”. All the website does is making a few requests and writing an Analyses including problem solving’s. There are no permanent disadvantages (bad requests/ DoS attacks and so on). Example: KnowYourStack.com ...

  • image1489-570x194.png
    „Sign in with Twitter“ for your own ASP.NET WebApp

      “Sign in with Twitter” is a popular practice to authenticate the users on your website. One advantage compared to an own registration is the lower inhibition for the user. But on the other hand Twitter doesn’t fess up with all the information’s and you will get into a kind of addiction. At the end ...

  • image1485-570x194_thumb.png
    CodePlex is going to be updated

      CodePlex the Microsoft Open Source Project Hosting Plattform hasn’t changed that much in the last few years and for a few times I thought Microsoft stopped the whole developing process. But now I found out that there is still life in the project. Maybe it is because of the success of GitHub or because ...

  • image1474_thumb.png
    What does Adobe in the flash-free web? Magazine-Style Layouts with CSS Regions!

      Adobe is well known for Photoshop and Flash but of course there is a lot more. According to the “Future Post” from Google Adobe declared one of their big subjects on a Blogpost. I’m talking about the W3C Working Draft to CSS Regions. Adobe cooperates with the WebKit Team and W3C on this. What ...

  • image1471-523x194.png
    HTML 5 Games, Tooling & 3D

      Game Developing is an interesting subject for all kind of software developer. But as a web developer without any Flash-skills there aren’t that much starting points. With HTML5 and the combination between Javascript, CSS3 and fast browsers there are the first “robust” HTML5 games. HTML5 games? Is this real? Neowin created a “Top 10” ...

Support us