A couple of months ago I was trying to explain the concept of unit test and test runners within Visual Studio for a couple of friends.
Needless to say there was some confusion around the fact that you needed a plug-in (TestDriven.Net/ReSharper) in order to run a plug-in (Gallio) that runs a plug-in (xunit-runner) in order to run your test from within Visual Studio itself.
So in order to get moving quickly we tried to figure out a better way and came out with a couple of ideas.
One was to configure the unit tests as a build event which also has the nice side effect that it is almost impossible to build the solution unless all tests pass.
Configure build events on all test projects
In our case we just called the xunit console runner with the current projects target path as argument.
$(ProjectDir)..\..\Libs\xunit\xunit.console.exe $(TargetPath)
(Make sure there are no spaces in the paths since it will as usual mess up things.)
Running the xUnit.net tests
Here is a screenshot of how it should look like if everything went fine.
The xunit output can be seen in the output window.
Not as fancy as graphical runner but it gets the job done.
Additional resources
Download the sample project used in this post.
More details on how to write xunit.net tests here.
Getting xunit to work in version 4 of the .NET-framework also requires some extra tweaking.
See running xunit.test in Visual Studio 2010 for more information.
(Note that the currently latest version of .NET 4 runtime is v4.0.21006.)

