Quantcast
Channel: ICT Blog » Microsoft
Viewing all articles
Browse latest Browse all 39

Using NUnit for your tests in Team Foundation Service with a Git repository

$
0
0

Since quite some time now it is possible to create a new project in Team Foundation Service (the cloud variant, not to be confused with Team Foundation Server) using Git for your version control. Since I’m an avid Git user I decided to see how the newly released Git tooling would work within Visual Studio and how easy it would be to migrate a project I’ve hosted on Github to Team Foundation Service.

I cloned my repository that I’m currently hosting on Github. This project already contains a MSBuild file for building the entire project. It also contains some unittests, written using NUnit.
Cloning the new project using Git
  • Great, now I have an empty local repository. Now to fill that repository. Using the commandline I went to the location of the new, empty repository. Then I simply used Git to retrieve all changes from my ‘old’ local Github repository with the command:git pull <location of local github repository> master –force
  • After that, it is simply a matter of pushing your changes to TFS.
Pushing the changes back to TFS.
  • Okay, now I had a filled repository on TFS. Next step was to create a builddefinition. I created a new definition and let it point to the build.proj MSBuild file that is found in the root of my repository. Queue new build and some moments later:
Build result
Tadaa! Using my own MSBuild file in the repository running in the build service of Team Foundation Service  resulted in a valid build. However, do you notice that warning icon at the bottom? It says: “No test is available in C:\a\bin\UnitTests.dll. Make sure that installed test discoverers & executors, platform & framework settings are appropiate and try again”.
So it looks like my tests aren’t being run.
I’m using NUnit for my unittests since I prefer it above the default MSTest framework. Team Foundation Service only has out of the box support for MSTest. However, Microsoft did something cool. They made it possible to use multiple testing frameworks in Visual Studio 2012.
Another testing framework only has to write an adapter interface and then it can be used by Visual Studio 2012. The plugin for NUnit can be found here. It is an extension for Visual Studio 2012.
Okay, so that gives me local support in Visual Studio to use NUnit. Now I want to add that testing functionality to the build server on my Team Foundation Service.
Luckily there is a way. You can configure the build controller to load additional assemblies to use. Simply use the following instructions to add the correct assemblies to the build controller.
One warning: the dialog on the build controller that asks you to specify the location of the custom assemblies, only gives you the possibility to retrieve those assemblies from a TFS repository. So Git is not yet supported in that way.Simply create a new empty project using TFS as version control and add the assemblies to a location. Then configure your buildcontroller to use those assemblies. My configuration looks like this:
After that, you can run the build again and now TFS will start using NUnit for the tests in your automated build. The end result:
Note that this technique also works with other testing frameworks like xUnit.
Hope this helps someone. Happy hacking!

The post Using NUnit for your tests in Team Foundation Service with a Git repository appeared first on ICT Blog.


Viewing all articles
Browse latest Browse all 39

Latest Images

Trending Articles





Latest Images