using TestCase attribute with arrays doesn't produce helpful output

Bug #465416 reported by cliff v.

This bug report was converted into a question: question #87575: using TestCase attribute with arrays doesn't produce helpful output.

6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Invalid
Undecided
Unassigned

Bug Description

If i have the following:

        [Test]
        [TestCase(new[]{2,1,2.1})]
        public void WithArray(params double [] prices)
        {
        }

It would be nice if NUnit could loop through the array and output it's contents and produce something like the following:

TestCase 'NUnitBugs.Tests.SampleTests.WithArray(System.Double[]{2,1,2.1})'
failed: TearDown : NUnit.Framework.AssertionException :
  Expected: 0.1m
  But was: 1.1m

instead of:

TestCase 'NUnitBugs.Tests.SampleTests.WithArray(System.Double[])'
failed: TearDown : NUnit.Framework.AssertionException :
  Expected: 0.1m
  But was: 1.1m

thanks

cliff

Revision history for this message
Charlie Poole (charlie.poole) wrote :

I converted this to a question because it seems like you may have misunderstood how to use TestCase. Of course, we can reinstate the bug if I misunderstood what you want.

If you make the argument to your test method an array, then NUnit will pass the array to it. OTOH, if you want NUnit to call your method multiple times with different arguments, you should use double as the arg type and either have multiple TestCase attributes(1) or use a ValuesAttribute on the parameter(2)

(1)
[TestCase(2)]
[TestCase(1)]
[TestCase(1.1)]
public void MyTest(double price) { ... }

(2)
public void MyTest(
   [Values(2,1,1.1)] double price ) { ... }

Changed in nunit-3.0:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.