JetBrains, the company behind the excellent Resharper has this build/integration server called TeamCity. I thought that you had to pay to use TeamCity, but the professional version is actually free!

I recently hit a problem with CruiseControl.NET and its limited security so I decided to try TeamCity. The installation was smooth and setting up a project and getting it to build a project (via NAnt) was easy. The problem is however that TeamCity only supports NUnit and since I use xUnit I did not get any test results presented in the TeamCity web interface.

In order to solve this I began writing a custom NAnt task. There is no NAnt xUnit task in the xUnit release or in the codeplex source repository but there is a task for MSBuild and it was pretty easy to port this to an NAnt task. When I had the NAnt task working I added some special log messages. The way you integrate with TeamCity is through specifically formatted messages, for example:

##teamcity[testStarted name='HomeContollerTester ']

##teamcity[testFailed name='testname' message='failure message' details='stack trace']

TeamCity expects live reporting, test by test, as it uses the started/finished messages to time each test and to provide more dynamic reporting while the tests are running. This doesn't play well with the xUnit test runner as there is no callback before each test is executed only after. The TeamCity test report will list all tests as if they executed in less than 1ms:


To solve this problem I added the ability to export the test results to a html file (this feature was already present in the MSBuild task). You can publish this html report as an artifact in TeamCity.

<xunit assembly="XUnitTeamCityTest.dll"        
       workingDir="${out.dir}" />
<echo message="##teamcity[publishArtifacts '${results.dir}\test_report.html']" />

The NAnt echo task will just output the message to the build log which TeamCity will parse. The full test report with accurate timing information will then be available in the TeamCity web interface. Like this:


I really like how easy it is to integrate artifacts from the build script to the build server and make those publicly available. I will try to contact the xUnit team and see if I can contribute this. TeamCity support is the highest voted feature request for xUnit on codeplex :)

But until then here is the source:


Andreas Öhlund said...

Interesting, I have recently started to evaluate Team City as or CI-server. We are currently on TFS but we are getting some Java-projects soon and I want a CI that can handle both .Net and Java hazzle free (you can tweek TFSBuild but TC seem much more powerfull than TFSBuild).

So far it looks promising and I really like the TC experience! ( no windows integrated security in the professional edition is a bit of a problem though)

Slava Imeshev said...


You might want to add our Parabuild to the list of Continuous Integration tools to look at. It works with NUnit and JUnit and can build .NET and Java projects out of the box. Parabuild Professional does provide integration with Active Directory and LDAP.

By the way, CruiseControl users are entitled to a 50% discount when ordering Parabuild.

lbarclay said...

Would this same approach work with Hudson?

Torkel Ödegaard said...

I am not sure, I haven't tried Hudson.