Reputation: 6180
Consider the following code:
private static object[] testStrings =
{
new object[] { "string1" },
new object[] { "string2" },
new object[] { "string3" },
new object[] { "string4" }
};
[Test, TestCaseSource("testStrings")]
public void CanParseString(string stringToTest)
{
//...
}
This then ends up massively polluting the test results like in the following image. Now imagine when there are dozens of tests each with several sets of test data.
Is there a way of forcing NUnit/Visual Studio to only show just the test that was run and not each individual piece of test data that was passed to said test?
Or perhaps I've set the TestCaseSource up wrong in which case I'd appreciate knowing where I've gone wrong.
Upvotes: 0
Views: 197
Reputation: 18649
I don't think you can, and as @adrianbanks alludes to in the comments you probably shouldn't.
From the NUnit documentation on Parameterized tests:
Multiple sets of arguments cause the creation of multiple tests.
Because the TestCaseSource
argument (and indeed TestCase
) expose multiple tests to the test runner, you can't get Visual Studio to regroup these as a single test.
Upvotes: 2