← 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

cliff v. gave more information on the question:
Charlie,

I guess i should have included a better example.  This is what I would
have:

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

i would be writing code that actually needed a list of numbers to process,
so your examples wouldn't help me.

hope this helps clear up my request.

cliff

On Fri, Oct 30, 2009 at 6:41 PM, Charlie Poole <
question87575@xxxxxxxxxxxxxxxxxxxxx> wrote:

> Your 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 direct
> subscriber of the question.
>


-- 
thanks

cliff

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