The problem is that the C# syntax appears to suggest that the pairs
of attributes are associated in some way, but they actually aren't.
This...
[TestFixture("string1"), Category("A")]
[TestFixture("string2"), Category("B")]
is equivalent to this...
[TestFixture("string1")]
[Category("A")]
[TestFixture("string2")]
[Category("B")]
and also to this...
[TestFixture("string1")]
[TestFixture("string2")]
[Category("A")]
[Category("B")]
or even this...
[Category("B")]
[TestFixture("string1")]
[TestFixture("string2")]
[Category("A")]
All the attributes are applied to the element that follow them - the
class itself. So, the entire class gets both category attributes and the
two instances that NUnit creates using the TestFixture attributes also
have both categories. There is no way NUnit could do it any differently,
because this is simply how attributes work.
We could, however, provide a property on TestFixtureAttribute to
allow you to set the category for each instance separately. Then
you would use a syntax like...
[TestFixture("string1", Category="A")]
[TestFixture("string2", Category="B")]
We don't have such a property right now, but we have others on both
TestFixtureAttribute and TestCaseAttribute. If you would like to request
it as a feature at http://bugs.launchpad.net/nunitv2, we'll see about
adding it in a future release.
Charlie
> --
> You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
> To post to this group, send email to nunit-...@googlegroups.com.
> To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
>
>
I'm not sure how this relates to the issue of Category selection.
Charlie
I'm not sure how this relates to the issue of Category selection.
Charlie
Nope, that doesn't do the job. Oleg wanted to use the same fixture
twice, with different arguments and different categories.
Of course, he could copy the class code and create a separate one for
category B, but that doesn't scale very well. :-)
Yes, I'd do that if the differences in context were not easily
parameterized. You'll find that the use of parameters is somewhat
weaker for test fixtures than it is for test methods, so this is
often needed.
Charlie