← Back to team overview

nunit-core team mailing list archive

Re: [Question #87575]: using TestCase attribute with arrays doesn't produce helpful output

 

Question #87575 on NUnit Framework changed:
https://answers.launchpad.net/nunit-3.0/+question/87575

Charlie Poole posted a new comment:
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 ) { ... }

-- 
You received this question notification because you are a member of
NUnit Core Developers, which is an answer contact for NUnit Framework.