NAnt does not work NUnit tests

I am using NUnit 2.5 and NAnt 0.85 to compile the .NET 3.5 library. Since NAnt 0.85 does not support .NET 3.5, I added an entry for frame 3.5 to NAnt.exe.config.

'MyLibrary', but when I click the "test" target to run NUnit tests, none of them start.

[nunit2] Tests run: 0, Failures: 0, Not run: 0, Time: 0.012 seconds 

Here are the entries in the NAnt.build file for creating and running 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 a problem with the version I need to know about? Test.dll works fine in the NUnit GUI.

Testing the dll is definitely found, because if I move it, I get the following error:

Run test (s). If the assembly is not built using NUnit 2.2.8.0 ... Failed to load the file or assembly "Test" or one of its dependencies ...

I would appreciate it if someone could point me in the right direction or describe a similar situation that they faced.

Edit I have since tried it with NAnt 0.86 beta 1, and the same problem occurs.

+4
source share
3 answers

The Nunit2 Nant task is still hard-coded to use the Nunit 2.2 library.

See docs: http://nant.sourceforge.net/release/latest/help/tasks/nunit2.html

"Runs tests using the NUnit V2.2 framework"

You can sort this with assembly binding redirection, however I think the recommendation is to use Nant <exec> and invoke the NUnit 2.5 console runner directly.

eg:.

  <!-- Run Unit Tests under NUnit 2.5 --> <exec program="${LibraryPath}\NUnit\2.5.7\nunit-console.exe"> <arg value="${SourcePath}\ProjectName.Tests\bin\Release\ProjectName.Tests.dll" /> </exec> 

Much easier.

I run this through TeamCity, and the unit test output still behaves correctly.

+9
source

I have no experience editing manually the NAnt 0.85 configuration. Perhaps you should try the last nightly one from NAnt (0.86 beta 2). Using this version, we build all of our .NET 3.5 projects without any complaints.

+1
source

To test your health, did you include the appropriate NUnit attributes in your test classes? These attributes are hooks with which NUnit determines which classes are test devices and which methods are test cases.

In the past, I made a mistake not to include the corresponding attributes and run tests without visible results. It is simple, but just make sure.

0
source

All Articles