In my previous post, I have explained how developers can take benefit of NUnit framework to develop and execute test cases in new Visual Studio 2012. This post is the next logic step to make those NUnit test cases run as part of a TFS build. This is more easily possible with new Test Runner that comes with Visual Studio which can handle execution of unit tests not only developed using Microsoft Unittest Framework but also other famous 3rd party unit test frameworks like NUnit, xUnit etc. Lets see how we can make TFS build execute NUnit based unit tests.
- If you have not, install the NUnit adapter for Visual Studio 2012 from Tools > Extensions menu
- Create a new folder in your team project source from Source Control Explorer, you can name it whatever suites - I named it BuildFramework. Then add the NUnit dlls that you got as part of the extension install to this source location. You can find those typically under - C:\Users\<current user>\AppData\Local\Microsoft\VisualStudio\11.0\Extensions\
- Now, let your build controller know that it has to consider some extra assemblies as part of build execution. This can be done by editing build controller properties. Go to Team explorer > Builds > Actions and Select Manage Build Controller. Then select the build controller and click on properties. On the build controller properties select the above created folder from source location containing NUnit assemblies as “Version control path to custom assemblies”
- That is it! Now next time you run your continuous build that is set to run “unit tests” will execute unit tests developed using NUnit framework alongside Visual Studio unit tests.
( 1 Vote )