Integrate NUnit with TFS
At work, we are migrating to TFS so we are rather newbies. Our team has written a lot of unit tests for our projects with NUnit and we've made extensive use of it's features (inheritance of test cases, collection asserts, etc.). Because we have so many unit tests with NUnit, it seems logical to keep them for a while instead of rewriting them. Is it possible to integrate NUnit with TFS. I already found a build task for NUnit (http://msbuildtasks.tigris.org/). But is it possible to have the same reporting features as with MS Test and how? Is it possible to create work items when a tests fails during a build? I figure that it doesn't work out-of-the-box, but is it possible to use NUnit instead of MS Test with the same level of integration after some tweaking and custom integration steps?
Thanks in advance,
Jan
Answers
Hi Jan,
1) The answer is "Maybe". It would be very difficult in V1 to get the same reporting functionality with NUnit that you get with MSTest. In fact, I wouldn't know how to do it myself. In Orcas (our next version), you can acheive a lot more, because we have separated out the information that appears in the build report and the information that is stored in the Published Tests Results database. We also have web services and even Object Model methods that allow you to put any information you like into the build report. The information in the warehouse is still driven from the Published test results database, but you can write a warehouse adapter to put in your own test results if you want (go here to learn more about that).
2) Yes, you can create work items during the build for whatever reason you want. We create a work item in a custom task when the compilation of the build fails. I would recommend that you write your own custom task to create work items. It should be straigtforward enough, if you use the Work Item Tracking Object Model. Make sure to reference Microsoft.TeamFoundation.WorkItemTracking.Client.dll.
3) I would say that in Orcas you could pull this off for sure!
Let us know if you run into any stumbling blocks,
Jason
All Replies
Hi Jan,
1) The answer is "Maybe". It would be very difficult in V1 to get the same reporting functionality with NUnit that you get with MSTest. In fact, I wouldn't know how to do it myself. In Orcas (our next version), you can acheive a lot more, because we have separated out the information that appears in the build report and the information that is stored in the Published Tests Results database. We also have web services and even Object Model methods that allow you to put any information you like into the build report. The information in the warehouse is still driven from the Published test results database, but you can write a warehouse adapter to put in your own test results if you want (go here to learn more about that).
2) Yes, you can create work items during the build for whatever reason you want. We create a work item in a custom task when the compilation of the build fails. I would recommend that you write your own custom task to create work items. It should be straigtforward enough, if you use the Work Item Tracking Object Model. Make sure to reference Microsoft.TeamFoundation.WorkItemTracking.Client.dll.
3) I would say that in Orcas you could pull this off for sure!
Let us know if you run into any stumbling blocks,
Jason
Hi Jason,
We''l let you know what we've come up with. Thanks for your response.
Jan
- Hi,
You might want to have a look at a project I recently released on codeplex that will integrate NUnit test results into TFS 2008 Team Build.
NUnit for Team Build (creative name!) is at http://www.codeplex.com/nunit4teambuild
- Richard Another possile third-party solution is here:
http://www.exactmagic.com/blog/2008/02/09/microsoft-team-system-nunit-adapter/I haven't tried it myself, but I thought I would pass it along.
Hi Jim,
From reading the blurb on the exactagic site it looks like they've got an adapter that allows team system tests (ie MSTest tests) to run within the NUnit testing framework.
It doesn't look like it will work the other way around.
- Richard


