Using runsettings file when running NUnit tests via command line

Tree55Topz

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.

Charlie

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. ;-)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

NUnit is ignoring DomainUsage in the runsettings file

Running compiled Java Selenium tests (with dependencies) using TestNG xml via command line

Running Java/Selenium/Cucumber tests via command line

"No tests found" when running jest from command line

Maven tests not running when executed from command line

Running command line arguments in NUnit Mono

Running tests using NUnit3 Console

How to compile and run C# files with NUnit tests from the command line on a Mac, using mono

Async methods not included in Code Coverage when using .runsettings file

Send file URL and args to (running) macOS app via command line

Using and running Tortoise svnsync in Windows via command line

Running php via command line

Configure the location of .coverage file when using /Enablecodecoverage in vstest.console.exe via command line

Is there a way to detect command line arguments not running tests?

Robolectric tests running in Android Studio but not on the command line

Maven not running tests from command line

Android - directory for running tests on the command line

When running node js file on command line not finding module

When running "./gradlew <task>" in command line, what file is read?

Problem in running an exe file in command line when there is space in paths of files

Batch file not running but works when I manually type in to command line

Different Behavior when running nunit tests from project and from solution

Running PHP file using command line as background process

"incorect command line error" when compressing file via subprocess

Convert ODS to CSV using command line when Libreoffice instance is running

Different behaviour when using a command line script or running it from a backgroundworker

How do I run nunit 2 tests from nunit-console from the command line?

Using .runsettings via commandline in MSTest.exe

Running jmeter .jmx tests locally using windows command line giving illegal argument exception