Archive for November, 2015

Specifying Custom NUnit Runner in MonoDevelop

2015/11/18

I just discovered that the NUnit Add-In in MonoDevelop has a nice although undocumented feature: you can specify a custom test runner in the .csproj file, either as an executable or as a type. If you have the NUnit.Runners nuget package installed in your solution/project and you want MonoDevelop to run the unit tests with nunit-console.exe instead of the built-in runner, you can add the following to your .csproj file:

   </PropertyGroup>
     <TestRunnerCommand>packages/NUnit.Runners.Net4.2.6.4/tools/nunit-console.exe</TestRunnerCommand>
   </PropertyGroup>

Now when you run your unit tests in MonoDevelop they will be run by nunit-console. This is useful when your unit tests make use of features that the NUnit Add-in doesn’t support yet, like ActionAttributes.

The other tags that are supported are:

  • TestRunnerArgs: Allows to specify additional command line arguments to the TestRunnerCommand
  • TestRunnerType and TestRunnerAssembly: allow to specify a test runner class/type and the assembly where to find this type.

If both TestRunnerArgs and TestRunnerType are specified, TestRunnerArgs takes precedence.