Question

I have written some Parameterized Tests, that use the ValueSourceAttribute for some of the test method arguments.

Here from the NUnit doc:

         | Complete Test Cases     |   Data for One Argument
---------|-------------------------|------------------------
Inline   | TestCaseAttribute       | RandomAttribute
         |                         | RangeAttribute
         |                         | ValuesAttribute
Separate | TestCaseSourceAttribute | ValueSourceAttribute

Is there anyway I can set the test description (specifically in the XML output) for the test cases generated by NUnit's combination of the parameters?

I'm using NUnit 2.5.9.

Was it helpful?

Solution

It's not possible with ValueSourceAttribute, because it would need to merge all descriptions from all ValueSource items of all parameters of the parameterized test.

When using the TestCaseAttribute you can give a description and a test name that should be passed into the result XML.

An example:

[Test]
[TestCase("abc", TestName = "Simple value", Description = "This test uses a simple input value")]
public void TestIt(string value)
{
  ...
}

There are also some other "special" parameters you can set, see here.

When you are absolutely keen about this feature, you can write your own TestCaseProvider addin. See the NUnit documentation for more information. This will likely solve your issue. But be warned, this is not a 5-minute thing.

OTHER TIPS

With [ValueSource(...)] there's no way, I'm afraid.

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