Question

NUnit 2.5 adds support for parameterized tests with attributes like ValuesAttribute and ValueSourceAttribute so that one can write something like:

[Test]
public void MoneyTransfer(
    [Values("USD", "EUR")]string currency,
    [Values(0, 100)]long amount)
{
}

and get all permutations for parameters specified. Priceless. However, it would be cool to specify (override) those parameters directly in NUnit GUI before pressing 'Run'. Unfortunately there is no such functionality in NUnit (yet?). Is there an alternative tool or testing framework allowing me to specify parameters before running a test (something like i can provide parameters in WcfTestClient.exe)?

Was it helpful?

Solution

One option could be to try out the TestCaseSource attribute that's supported - basically, you can define an IEnumerable method as source of data for a test - and within that, you can look anywhere you like for test data - could be to pull from a database/flat file/iterater round files in a given directory etc.

Have a look at that, it's a handy thing to know about.

OTHER TIPS

Unit test are supposed to run automatically and be reproducible. By changing test at runtime you break this behavior. So I don't think this is something you want to do...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top