5

Parameterized Unit Testing is great when you have X unit test * Y configurations.

I have 3 unit tests, and each must run in 5 particular situations.
I use xUnit.net's Theory/PropertyData feature, it works well.

PROBLEM: In the Test Runner UI, there is one green/red symbol per unit test, which means 3.
It makes it difficult to evaluate progress: the symbol is red until ALL configurations work perfectly.
I want 15 symbols, one per unit test * configuration, to know what particular combination is going wrong.

xunit.net has yet to implement the feature to show 15 symbols.

I am willing to switch to another test framework just to get this feature.
QUESTION: Does any .NET test framework have this feature?
Any kind of reporting is fine (GUI, HTML, etc)

enter image description here

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373

3 Answers3

6

You can use TestCaseAttribute or TestCaseSourceAttribute of NUnit to specify different parameters for test. Each test case will be shown as separate test in test runner.

Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459
2

NUnit console will show you which test case failed. Example:

[TestCase("ABK")]
[TestCase("bgba")]
[TestCase("CBVS")]
[TestCase("DSBH")]
[TestCase("E")]
[TestCase("FJMC")]
[TestCase("HBTV2")]
[TestCase("JFFC1")]
[TestCase("K")]
[TestCase("LBHG")]
[TestCase("MJCM")]
[TestCase("PHJL")]
[TestCase("R")]
[TestCase("TDPP")]
[TestCase("UGV")]
[TestCase("VXHC")]
[TestCase("YFD")]
public void Given_a_main_supplier_categorie_then_it_should_return_a_collection_of_RM_categories(string supplierCategory)
{
     // test code here
     // ....           
}

See the attached screenshot. Also, Resharper has great support for Unit Testing.

NUnit console

Rui Jarimba
  • 11,166
  • 11
  • 56
  • 86
0

Pretty sure TeamCity renders them from xUnit.net individually. I reckon the TeamBuild tooling should pick them up too as they go into the report data.

The xUnit.net GUI and console runners identify the arguments of failing cases.

Any particular reason why you feel its of benefit to show the passing individual cases? (i.e. are you trying to get a readable report?)

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
  • You're right, I want readable reports, so that bosses can understand the situation better. Actually, there are 5 parameters, 4 are green but the last 1 is red (because of a bug independent from us). So all unit tests are red, which makes it difficult to find out when bugs have been introduced in the 4 others. – Nicolas Raoul Nov 16 '12 at 05:48
  • @NicolasRaoul In that case, I'm pretty sure xUnit.net does log themthe parameters in the reports - I am not 100% on whether each row counts as an item (guess it it does). I'm not sure if the style sheet they layer on in the report shows the items. Well worth running xunit.console with the report option and having a look. Obviously where/how the report is going to be presented is your real thing to figure out. BTW CodeRush shows them individually in the IDE and I'm sure Resharper does too (or they can easily be guilted into adding it in a flash if it doesnt) – Ruben Bartelink Nov 16 '12 at 10:53