Pass parameters via the command line to NUnit

There seems to be no solution at the moment. The best option is to use NUnit project files, modify settings there and pass the solution file to the runner.


Use an environment variable to pass the information.

Use set from the command-line or <setenv> from NAnt. Then read the value using Environment.GetEnvironmentVariable().


NUnit 3 now allows passing parameters. Here is the usage

nunit3-console [inputfiles] --params:Key=Value

From the documentation

--params|p=PARAMETER

A test PARAMETER specified in the form NAME=VALUE for consumption by tests. Multiple parameters may be specified, separated by semicolons or by repeating the --params option multiple times. Case-sensitive.

Here's how you can access the parameter through code:

var value= TestContext.Parameters.Get("Key", "DefaultValue");