How to run NUnit v2.4.8 tests using NAnt 0.86 beta?

I recently tried using NAnt (beta 0.86.2962.0) to run some unit tests compiled with the latest stable version of NUnit (v2.4.8) without any success.

The error I am getting is the following:

[nunit2] The assembly "C: \ Dev \ MySample \ bin \ tests \ My.Sample.Tests.dll" does not contain tests.

Of course, the assembly contains tests that I can run from any runner, for example, NUnit one, TestDriven or Resharper. I would like to use the <nunit2> task, not the <exec> one directly, but I wonder if this is possible, even using the app.config files to link build versions.

+6
unit-testing nunit nant
source share
1 answer

I don’t remember why, but I refused to use the <nunit2> task, and I successfully used the <exec> task and nunit-console.exe. If this helps, here is my test goal that runs NUnit and FxCop. Note that it skips them if the executable files are not in the Windows path.

<target name="test" description="Run unit tests" depends="build"> <property name="windows-path" value="${string::to-lower(environment::get-variable('PATH'))}"/> <property name="nunit-in-path" value="${string::contains(windows-path, 'nunit')}"/> <echo message="Tests skipped because no NUnit folder was found in the Windows path." unless="${nunit-in-path}"/> <exec program="nunit-console.exe" if="${nunit-in-path}"> <arg file="../MyProject/MyProjectTest.nunit"/> </exec> <property name="fxcop-in-path" value="${string::contains(windows-path, 'fxcop')}"/> <echo message="FxCop skipped because no FxCop folder was found in the Windows path." unless="${fxcop-in-path}"/> <fxcop projectFile="../MyProject/MyProject.fxcop" directOutputToConsole="true" failOnAnalysisError="true" if="${fxcop-in-path}"/> </target> 
+10
source share

All Articles