2

I am using below to pass a single parameter to my Test.

C:\Documents and Settings\>"C:\Program Files\NUnit 2.6.2\bin\nunit-console" "D:\Automation\ClassLibrary2\bin\Debug\ClassLibrary2.dll /run:ClassLibrary2.Class1.Test1(\"option1\")

MyCode:

namespace ClassLibrary2
{
    [TestFixture]
    public class Class1
    {
        [Test]
        public void Test1(string browser)
        {
            MessageBox.Show(Browse );
        }

    }
}

Result: Tests run: 0, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0 seconds

So how to Pass parameters directly from nunit-console to Test.

flexdroid
  • 8,437
  • 2
  • 21
  • 27
Kishore reddy
  • 71
  • 1
  • 4

1 Answers1

0

The way that I have normally solved the problem is by allowing environment variables to override configuration properties.

Then I can control the environment variables from build scripts, build servers, etc. to control that the tests run in the environment that I want them to.

For example:

[TestFixture]
public class DataAccessTest
{
    static string GetConnectionString() {
        return Environment.GetEnvironmentVariable("ConnectionStringForTest") ?? DefaultConnectionString;
    }

    [Test]
    public void Test() {
        var context = new DataContext(GetConnectionString());
        ...
    }
}
Pete
  • 12,206
  • 8
  • 54
  • 70