R – NAnt, MbUnit, CruiseControl, Selenium – passing settings to the test assembly

cruisecontrol.netmbunitnantselenium

I am putting together some ideas for our automated testing platform and have been looking at Selenium for the test runner.

I am wrapping the recorded Selenium C# scripts in an MbUnit test, which is being triggered via the MbUnit NAnt task. The Selenium test client is created as follows:

selenium = new DefaultSelenium("host", 4444, "*iexplore", "http://[url]/");

How can I pass the host, port and url settings into the test so their values can be controlled via the NAnt task?

For example, I may have multiple Selenium RC servers listening and I want to use the same test code passing in each server address instead of embedding the settings within the tests themselves.

I have an approach mocked up using a custom NAnt task I have written but it is not the most elegant solution at present and I wondered if there was an easier way to accomplish what I want to do.

Many thanks if anyone can help.

Best Answer

Thanks for the responses so far.

Environment variables could work, however, we could be running parallel tests via a single test assembly so I wouldn't want settings to be overwritten during execution, which could break another test. Interesting line of thought though, thanks, I reckon I could use that in other areas.

My current solution involves a custom NAnt task build on top of the MbUnit task, which allows me to specify the additional host, port, url settings as attributes. These are then saved as a config file within the build directory and then read in by the test assemblies. This feels a bit "clunky" to me as my tests need to inherit from a specific class. Not too bad but I'd like to have less dependencies and concentrate on the testing.

Maybe I am worrying too much!!

Related Topic