During 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.
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.
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
Take a deeper look on the second step:
NUnit Testrunner Configuration:
We´ve installed NUnit Version 2.5.8 and in the textbox "Run tests from" is this included:
Because 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:
With the filter you instruct dotCover which Code should be recognized for the CodeCoverage during UnitTesting.
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:
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:
Code Coverage for the Assemblies:
Here you can see what will run or not beside of the .cs file:
And here we have a nice little overview:
Useful and easy and it doesn´t take a lot of time.