Using NUnit 2.5 or xUnit.NET 1.5 with .NET 4.0 Beta 2

by Michael F. Collins, III October 28, 2009 12:51

I started playing with .NET 4.0 and Visual Studio 2010 over the weekend. I quickly came to an interesting problem however. I switched a while ago on .NET 3.5 to using xUnit.NET instead of NUnit or the unit testing in Visual Studio 2008. I like to redistribute my test suites with my products as a support aid for end-users that are using my applications. Since I can’t redistribute the Visual Studio testing assemblies, I prefer the open source frameworks. But the problem that I quickly discovered was that neither xUnit.NET or NUnit supported .NET 4.0 yet, which is completely understandable. I figured out a couple of configuration changes that could be applied though to get unit tests to work and run in the .NET 4.0 runtime.

Both xUnit.NET and NUnit have application configuration files for their respective test runners. The first thing that you need to do is tell the standard CLR host to load the test runners using the .NET 4.0 CLR runtime. This can be done by adding a element to the configuration file:


    
        
    

This will cause both NUnit and xUnit.NET to use the .NET 4.0 CLR instead of the .NET 2.0 CLR.

I further discovered that NUnit had some problems loading the nunit.core.dll assembly from the lib private subdirectory. I was able to get around this problem by adding the following fragment to the element in the configuration file for NUnit’s test runners:


    
        
    

After making these changes, I had no issues running my test suites with either NUnit or xUnit.NET.



Tags: , ,

.NET Framework | TDD | Unit Testing

Comments

11/5/2009 11:13:37 AM #

trackback

Social comments and analytics for this post

This post was mentioned on Twitter by xUnit.net Updates: RT @mfcollins3: New blog post: Using NUnit 2.5 or xUnit.NET 1.5 with .NET 4.0 Beta 2 http://bit.ly/Fq8m6

uberVU - social comments

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen | Modified by Mooglegiant

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

What I'm reading now


Add to Technorati Favorites

Disclaimer

The views expressed on this website/blog are the opinions of Michael F. Collins, III, and do not necessarily reflect the views of my employer.