pátek 20. června 2014

xunit and visual studio online

I like xUnit and I’d like to use it on our projects that will be hosted in visual studio online (tfsonline). Particularly I need to run xunit tests during the build process on hosted build server. VSO offers hosted build servers and it has native integration for running ms tests and it is extensible so it is possible to put xunit (or other unit testing frameworks) to the build chain. This blog post about how to setup the project and the build controller to be able to run xunit tests.

Setup VisualStudio 2013 to run xunit test

First of all it’s good to setup visual studio to be able to run xunit tests locallyJ The easiest way is to use nuget references. The basic package is xunit.net package, this has the implementation of simple xunit tests (Facts). We need data driven tests too (Theory), this is included in the second package from the picture xunit.net.extensions. 

Lastly download the xunit test runner to visual studio, this is a visual studio extension which will run the xunit test inside visual studio.

Setup for running on Hosted build server

You need to include another nuget package which containes the test runner for xunit. This will discover xunit tests in assemblies and run them.
Nuget packages are automatically downloaded during the build process to the hosted build server, we don’t need to do anything. 

On the internet there are lot of tutorials how to push custom assemblies to the build controller in order to get them to hosted build server. This setup is only needed if you don’t have the assembly as a nuget reference.
Few links for manually configure the build controller: