I’ve been using xUnit.Net for a while now. It’s just a tiny bit cleaner and slightly less abrasive than other .Net unit testing frameworks. Leaving out unnecessary stuff like [TestFixture] and shortening Assert.AreEqual to the equally clear but shorter Assert.Equal don’t seem like big improvements but when you type them several times a day tiny improvements start to add up. I also like the use of the [Fact] attribute instead of [Test]. It shifts the focus from testing to defining behavior. So how do we get all this goodness working with the Visual Studio 2010 beta?
Creating tests is as easy as it normally is, you can just reference xunit.dll it in your 4.0 test-projects. Running your 4.0 tests can be a problem, the testrunners included in the xUnit.net package are compiled against the 2.0 framework so they won’t load 4.0 test-assemblies.
The obvious solution is to just download the source and compile it yourself. (+1 for open source!) Make sure you select the .Net Framework 4 and not the .Net Framework 4 Client profile in the project properties for the console runner because it uses some logging functionality that’s not available in the client profile. Everything will just run after this.
I found an easier solution on Mark Needhams blog In his article xUnit.NET: Running tests written in Visual Studio 2010 he explains how you can run the 2.0 console runner with the 4.0 clr by adding a section to the .config file instead of recompiling the whole thing. Adding the following lines to the xunit.console.exe.config should do the trick;