Re: [nunitv3] Re: Another Question of Naming
"Charlie Poole" <[email protected]> Tue, 9 Sep 2008 05:49:49 -0700
| Newsgroups | gmane.comp.windows.dotnet.nunit.devel |
|---|---|
| Message-ID | <001501c9127a$8c626ae0$6401a8c0@ferrari> |
Hi Olof, > 2008/9/9 Charlie Poole <[email protected]>: > > > > Hi All, > > > > I'm still not happy with one of the attribute names we are > using for > > parameterized tests, so I'm asking for ideas, opinions and > > suggestions. > > > > Here's what we have now... > > > > You can specify entire test cases together or individual values for > > parameters, which NUnit then combines into test cases using various > > strategies. > > > > If you go with full test cases, they can either be inline or > > separately named and referenced... > > TestCase( 1.2, 3.0 ) // Inline > > TestCases( "myCases") // Separate > > > > Similarly, if you go with individual parameters, they can > be inline or > > separate... > > Values(12, 7, 3) // Inline > > DataSource("myValues") // Separate > > I'm not 100% how this "paramater values" version of test cases work. > > I understand TestCase and TestCases (even though TestCases is > a bit ambious to me since it actually specifies a named > source of TestCase-tuples, but it's so readable anyway) Yes, I considered TestCaseSource, which is literally more exact, but I liked TestCases with the notion being "The test cases are to be found here" > Could you give an example of the Values, DataSource including > a [Test]-method (or TestCase method if that is the way to use them..)? Here's one - a bit contrived, but illustrative... [Test] public void AdditionIsCommutative( [Values(0, 1, 42, 99)] int a, [Values(1000, 2000)]int b) { Assert.That( a+b == b+a ); } Since the default strategy is combinatorial, this would generate 8 test cases. The equilent with datasource would use [DataSource("xxxxx")] and [DataSource("yyyyy")] for the attributes, were xxxxx and yyyyy would be declared elsewhere in the class, probably as arrays of ints. Specifying parameter values separately is a key to more advanced techniques like Pariwise and Combinatorial testing and Theories. I've also used it with a Sequential strategy (just use the args in sequence) when I needed to pass argument 1 to method 1 and arguments 1 and 2 to method 2. Charlie > > > > We'll be adding others - cases in a spreadsheet, etc. - but > these are > > the four basic ones. > > > > I'm quite happy with TestCase, TestCases and Values. > > I find them quite readable and others have said the same. > > > > But DataSource strikes me as a bit too generic. It doesn't tell me > > that it's a set of single parm values rather than a test case. It > > sounds like it might have something to do with a DB. But > for the life > > of me I can't think of anything better. > > > > Ideas? > > > > Charlie > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the > Google Groups "NUnitV3" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nunitv3?hl=en > -~----------~----~----~----~------~----~------~--~--- > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/