Specifying Custom NUnit Runner in MonoDevelop

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s