Is it somehow possible to pass values to NUnit tests via the command line?
My tests use a certain URL. I have different instances of my code at different URLs and would like to specify the URL via the command line. File App.config
is not an option, because I want to run the tests for different URLs via a batch file.
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");