22

What is the best way to integrate nunit tests into TFS 2010? Is it via generic tests or is there a better approach to running them?

Ideally I'd like to have the granularity of one generic test per test assembly and have a way to surface the results in the TFS build report.

Kevin McMahon
  • 2,643
  • 25
  • 31

3 Answers3

20

As of now (Oct 2011), the easiest way is probably via the NUnit activity that can be found in the Community TFS Build Extensions.

LordHits
  • 5,054
  • 3
  • 38
  • 51
12

You can run nunit tests from command line and therefore you can automate these tests via your (Workflow) build template.

Since there aren't a lot of custom build activities available for TFS 2010 yet, you could write your own to make sure that it integrates better with the TFS Build Report. Here you can find some information about writing a custom build activity.

Another approach would be to create unit tests via Visual Studio. These tests will be automatically run when performing a build.

Community
  • 1
  • 1
Rhapsody
  • 6,017
  • 2
  • 31
  • 49
  • Yes I am currently wrapping nunit-console in generic tests but there is a lot of friction to it. I shied away from the WF option due to the lack of integration with the build report. I've also found this link http://blog.salvoz.com/2010/02/22/RunningXUnitFromTeamBuild2010AndPublishingResults.aspx which affirms what I feared and goes along with what you're saying about customizing the WF. I was hoping for a better solution than the WF but this will suffice while we port over a sizeable amount of legacy tests. Thanks and I'll accept the answer. – Kevin McMahon Mar 23 '10 at 15:13
  • I've been playing around with WF as well and after a while it works pretty well. But I suggest to look again when the final version of TFS 2010 is there. Although I don't expect a lot of changes, there maybe some small improvements. Good luck further!! – Rhapsody Mar 23 '10 at 15:25
  • Any update on this? Are you aware of any custom build templates for doing this, or do I still need to roll my own? – Phillip Wells Jul 19 '10 at 19:51
  • Personally I'm not using NUnit. We're using the Microsoft Test framework and those test assemblies are automatically executed during build. Maybe this will help you: http://www.codewrecks.com/blog/index.php/2009/07/19/integrate-nunit-test-into-a-tfs-build/ – Rhapsody Jul 20 '10 at 05:47
1

Ian Battersby wrote a great tutorial how to set up NUnit tests for Visual Studio 2010.

Basically, you need to:

  • download his build workflow template and set to your build definition
  • install NUnit and NUnitTFS in your tfs machine
  • add paths to installed directories in build process parameters
  • set Configurations to Build setting in build process parameters
  • change your NUnitTfs.exe.config with your collection name
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
Bomberlt
  • 259
  • 1
  • 8
  • 21