views:

106

answers:

1

I have an Nunit test which uses selenium RC to run tests against our UI. I want to run the tests against 2 different servers, which means having the call to selenium.open() with 2 different servers. However, I don't want to have 2 different Nunit test suites that do the same thing but against different servers. I need a way of passing parameters from Nant or the Nunit driver program to specific which server to test against.

Is there anyway to do this?

A: 

If you're looking to run the same tests against both servers, the latest version of NUnit supports tests which take parameters. You could include a server argument to your tests like this:

[TestFixture]
public class MyTestFixture
{
    public string[] Servers = new string[] { "server1.address", "server2.address" };

    [Test]
    public void SomeTest([ValueSource("Servers")] server)
    {
        ISelenium selenium = new DefaultSelenium(server, 4444, "*firefox", "http://localhost");
        //rest of test
    }
}

When NUnit executes, this test will be run twice: once with the "server1.address" parameter and once with the "server2.address" parameter. You can read up on ValueSource tests here: http://www.nunit.org/index.php?p=valueSource&r=2.5.5

Wesley Wiser