I am trying to figure out how to get TeamCity 4.0 (Build 7888) to display NUnit test results when ran from PartCover inside an MSBuild script. There has GOT to be someone out there that either 1.) wants the same thing or 2.) has already achieved this. I mean, come on… it is almost the year 2009. :) Here is some background information…
I have read numerous posts on how to get TeamCity to run NUnit using MSBuild so that the NUnit results are displayed in TeamCity. This doesn’t seem to be a problem as you can run NUnit with the TeamCity NUnit Test Launcher as described in this link in the documentation:
This link essentially tells you to define the NUnit task to be the TeamCity NUnitLauncher MSBuild Task. That is great, but what if you want to generate coverage reports? I have found a few posts on how to do this with NCover. They are as follows:
The problem with these Tech Brother’s posts (though they are VERY well written) is that the unit tests are run twice, once so TeamCity can capture the test history and a second so NCover can capture the code coverage. This is not ideal and is mentioned in the following posts that talk about this problem and present a better solution:
which reference this post where the solution originally came from:
These posts are GREAT as long as you want to use NCover. This solution essentially tells NCover to profile TeamCity’s runner process, not the NUnitLauncher process.
So let’s recap… with the last links, you can get TeamCity + MSBuild + NUnit + NCover to work. However, what about PartCover? LOTS of people use PartCover. I don’t believe that PartCover has the ability to attach to a running process like NCover does (with its use of the profileProcessModule attribute). So how would this work? Yes, you could pass the TeamCity NUnitLauncher exe to PartCover (just like they did with NCover), but this wouldn’t do any good since PartCover can’t attach to a different spawned process like NCover does. This would prevent the above solution from working using PartCover instead of NCover.
So… what about using the TeamCity NUnit addin? This REALLY sounds promising… Perhaps this is the key to getting TeamCity + MSBuild + NUnit + PartCover to work. Let’s check some documentation…
This says the following :
“TeamCity Addin for NUnit allows you to enable on-the-fly tests reporting from NUnit tests runner. TeamCity provides this addin for NUnit 2.4.6 and NUnit 2.4.7.”
This is EXACTLY what I want since I am going to be calling the original NUnit test runner with PartCover.exe. Apparently all I have to do is copy the following files from “C:\TeamCity\webapps\ROOT\update\plugins\dotnetPlugin.zip\dotnetPlugin/bin” to my Unit addins folder.
- JetBrains.TeamCity.NUnitAddin-NUnit-2.4.8.dll (2.4.7 is out there too and I tried that as well)
- JetBrains.TeamCity.NUnitAddin-NUnit-2.4.8-pdb (2.4.7 is out there too and I tried that as well)
I did this exactly as stated on the documentation link, but it didn’t work. These files had some dependencies that were not loading up. I also had to copy these files to the NUnit addins folder to get the TeamCity NUnitAddin to actually load up in NUnit. In fact if you use Reflector on JetBrains.TeamCity.NUnitAddin-NUnit-2.4.8.dll, it will have references to the below files. (UPDATE: I have since removed these files from the NUnit addins folder and the TeamCity NUnit Addin still loads up… so I am REALLY confused.)
So, now that all 4 .dlls were in the NUnit addins folder, when NUnit ran, the TeamCity NUnit Addin actually loaded up which is shown in the NUnit log file “C:\NUnitPrimaryTrace.txt” with the below entries:
Registered addin: Teamcity Listener
I am taking this to mean that when the original NUnit runner is called, the TeamCity NUnitAddin is actually loading up inside of NUnit. So, given that, you would expect the tests results tab to show up in TeamCity, right? Wrong. At least not for me due to whatever I am doing wrong here. I can check the build.out folder of my build process and the tests ran and the coverage report was generated, but TeamCity didn’t have anything show up. It seems that the addin is loading up but TeamCity isn’t doing anything with it.
So to make a long story even longer, we are back to my original question… it is the question that drives us (at least me). How do you get TeamCity + MSBuild + NUnit + PartCover to actually work? It really seemed like the TeamCity NUnit addin was the answer, but it doesn’t seem to be working. I have also been reading up a bit about Gallio (http://www.gallio.org) and I believe that it has TeamCity integration and can also work with PartCover, but I have not gone down that path yet. Perhaps that is the solution I am looking for, but I sure thought that TeamCity NUnit addin was going to solve my problems. Am I not understanding its functionality properly? I assumed that it was the way to get TeamCity to listen if you are using the original NUnit runner (which is required if you are using PartCover).
I apologize if I have missed something or misunderstood something. I didn’t want to post without first trying everything I could think of as well as scouring the Internet for possible solutions, but it seems that no one has pulled off TeamCity + MSBuild + NUnit + PartCover yet. This makes me scratch my head. I can’t possibly be the only person that wants to figure this functionality out, but if someone has figured it out, either they didn’t post it or I didn’t find it.
Thanks for reading this, and feel free to blast me on any mistakes I have made. Any help is certainly appreciated.
Oh... also, just for more enjoyable reading, here is a post to get NDepend running in TeamCity. I know that this post is not about that, but anyone reading this would probably be interested. As soon as I figure TeamCity + MSBuild + NUnit + PartCover out, I am going to add NDepend to the equation.
Edited by: staylor15 on Nov 7, 2008 1:10 AM
Edited by: staylor15 on Nov 7, 2008 1:21 AM