I'm using NUnit 2.5 and NAnt 0.85 to compile a .NET 3.5 library. Because NAnt 0.85 doesn't support .NET 3.5 out of the box, I've added an entry for the 3.5 framework to NAnt.exe.config.
'MyLibrary' builds, but when I hit the "test" target to execute the NUnit tests, none of them seem to run.
[nunit2] Tests run: 0, Failures: 0, Not run: 0, Time: 0.012 seconds
Here are the entries in my NAnt.build file for the building and running the tests:
<target name="build_tests" depends="build_core">
<mkdir dir="Target" />
<csc target="library" output="Target\Test.dll" debug="true">
<references>
<include name="Target\MyLibrary.dll"/>
<include name="Libraries\nunit.framework.dll"/>
</references>
<sources>
<include name="Test\**\*.cs" />
</sources>
</csc>
</target>
<target name="test" depends="build_tests">
<nunit2>
<formatter type="Plain" />
<test assemblyname="Target\Test.dll" />
</nunit2>
</target>
Is there some versioning issue I need to be aware of? Test.dll runs fine in the NUnit GUI.
The testing dll is definitely being found, because if I move it I get the following error:
Failure executing test(s). If you assembly is not build using NUnit 2.2.8.0…
Could not load file or assembly 'Test' or one of its dependencies…
I would be grateful if anyone could point me in the right direction or describe a similary situation they have encountered.
Edit I have since tried it with NAnt 0.86 beta 1, and the same problem occurs.
Best Answer
The Nunit2 Nant task is still hardcoded to use the Nunit 2.2 library.
See docs: http://nant.sourceforge.net/release/latest/help/tasks/nunit2.html
You may be able to sort this out with assembly binding redirection, however I think the recommendation is just to use the Nant <exec> task and call the NUnit 2.5 console runner directly.
e.g.:
Much simpler anyway.
I am running this through TeamCity and the unit test output seems to still behave correctly.