Pass parameters via the command line to NUnit

Achim picture Achim · Jul 6, 2010 · Viewed 11.5k times · Source

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.

Answer

Brian Low picture Brian Low · May 23, 2011

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