Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit Parameterized tests: Setting the test description

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.

like image 574
Tully Ernst Avatar asked Jan 10 '14 08:01

Tully Ernst


1 Answers

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.

like image 174
Dio F Avatar answered Oct 12 '22 23:10

Dio F