views:

135

answers:

1

Hi there,

We're trying to migrate a .Net 3.5 solution into .Net 4.0, but are experiencing complications with the testing frameworks that can operate using an assembly that is built using version 4.0 of the .Net Framework.

Previously, we used NUnit 2.4.3.0 and NCover 1.5.8.0 within our NAnt scripts, but NUnit 2.4.3.0 doesn't like .Net 4.0 projects. So, we upgraded to a newer version of the NUnit framework within the test project itself, but then found that NCover 1.5.8.0 doesn't support this version of NUnit.

We get errors in the code saying words to the effect of the assembly was built using a newer version of the .Net Framework than is currently in use, as it's using .Net Framework 2.0 to run the tools.

We then tried using Gallio's Icarus test runner GUI, but found that this and MbUnit only support up to version 3.5 of the .Net Frameword and the result is "the tests will be ignored".

In terms of the coverage side of things (for reporting into CruiseControl.net), we have found that PartCover is a good candidate for substituting-out NCover, (as the newer version of NCover is quite dear, and PartCover is free), but this is a few steps down the line yet, as we can't get the test runners to work first!!

Can any shed any light on a testnig framework that will run under .Net 4.0 in the same way as I've described above? If not, I fear we may have to revert back to using .Net 3.5 until the manufacturers of the tooling that we're currently using have a chance to upgrade to .Net 4.0.

Thanks.

A: 

Right - have sort of fixed this myself. Here's how, in case anyone else has the same problem.

NUnit 2.5.5 is now out and this supports projects build using .Net Framework v4.0, but you have to use an additional parameter, namely /framework=4.0.30319, which looks something like this when used in NAnt, through NCover:

<exec program="C:\Program Files\TestDriven.NET 2.0\NCover\1.5.8\NCover.Console.exe">
 <arg value="&quot;C:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit-console.exe&quot;"/>
 <arg value="&quot;bin/release/myProject.Test.dll&quot; /framework=4.0.30319"/>
 <arg value="/xml"/>
 <arg value="bin/release/myProject.Test-dll-results.xml"/>
 <arg value="//x"/>
 <arg value="bin/release/myProject.Test-dll-coverage-results.xml"/>
 <arg value="//q"/>
 <arg value="//a"/>
 <arg value="myProject.Test"/>
</exec> 

With only upgrading NUnit to 2.5.5 (as well with adding this flag) this now works with very little change to the build scripts, which is good.

So, in summary:

My NAnt script calls out to NCover 1.5.8 and that calls NUnit 2.5.5 which tests my unit test assembly .dll that was built using .Net 4.0. NUnit generates the first output file (bin/release/myProject.Test-dll-results.xml), which is then picked up by NCover and is processed into the second output results file (bin/release/myProject.Test-dll-coverage-results.xml), which can then be simply included into Cruise Control's ccnet.config file for it's automatic inclusion within the webdashboard after each build.

Simple. Hope it helps someone else!

Brett Rigby