I created a runsettings file which looks like this
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<TestRunParameters>
<Parameter name ="environment" value="PROD" />
</TestRunParameters>
</RunSettings>
And then in my TestSetup portion (using LeanFT for UI tests) I specify that the target environment is contained under a paramater called environment
string env= TestContext.Parameters["environment"];
This doesnt seem to work, and I am not getting any particular error messages. Is this the right way to do this, or is there an easier way to just use Environment and something I pass into the command line.
You should be more specific than "via the commandline" since there are a number of ways that folks run NUnit tests from the command-line.
If you are using the nunit3-console.exe
runner, you pass run parameters to the framework using the --params
option, for example:
nunit3-console my.test.dll --params "environment=PROD"
The .runsettings
file is an artifact used by Visual Studio and recognized by the NUnit VS adapter, but not by NUnit itself.
You can use that from the command-line as well, using vstest.console.exe
. If that's what you are using, you want the /Settings
option in order to specify the file.
Two answers for the price of one! But if you are using neither nunit-console
nor vstest.console
you'll have to ask again. ;-)