Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

The error I get is the following :

[nunit2] Assembly "C:\Dev\MySample\bin\tests\My.Sample.Tests.dll" contains no tests.

Of course, the assembly contains tests that I can run from any runner, like NUnit one, TestDriven or Resharper. I would like to use <nunit2> task, and not directly the <exec> one, but I'm wondering if it is still possible, even using app.config files to bind assembly versions.

like image 838
Romain Verdier Avatar asked Sep 05 '08 08:09

Romain Verdier


People also ask

How do you run a test case in parallel with NUnit?

The NUnit 3.0 framework can run tests in parallel within an assembly. This is a completely separate facility from Engine Parallel Test Execution, although it is possible to use both in the same test run. By default, no parallel execution takes place.

How does NUnit decide what order to run tests in?

Ordered tests are started in ascending order of the order argument. Among tests with the same order value or without the attribute, execution order is indeterminate.


1 Answers

I can't remember why, but I gave up on using the <nunit2> task and I've been using the <exec> task and nunit-console.exe happily. If it helps, here's my test target that runs NUnit and FxCop. Note that it skips them if the executables aren't 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>
like image 76
Don Kirkby Avatar answered Oct 04 '22 01:10

Don Kirkby