This doesn't work because NUnit 2.x looks for attributes based on their Name. In
order to make it appear that inheritance works, we have to reflect down the
entire inheritance chain of any attribute we find. We only do this for the
attributes that are explicitly documented as supporting inheritance, for
example, TestFixture, Test and PropertyAttribute.
What you have found seems to me to be a bug. ExplicitAttribute should
really be final, since you cannot usefully inherit from it. However, I imagine
the fix you would prefer is to allow inheritance and make it work as you
intended. That would be a simple enough fix - just file a bug on it.
As a workaround, I usually use Explicit("NYI").
BTW, this issue will go away in 3.0, which is one reason I haven't paid
much attention to it in the 2.x series.
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.
>
>
[TestFixture] -> [Given]
[TestFixtureSetup] -> [When]
[Test] -> [Then]
and additionally
[Category("Integration")] -> [Integration]
etc.
Which might be abusing the framework but does provide us value. Do you
expect that this would change for us in the 3.0 world?
Thanks for the feedback, I'll submit a bug.
-Travis
By "useful" I meant that you can do it and NUnit doesn't ignore you. IMO,
any inheritance that NUnit will simply ignore should be disallowed at
compile time. Otherwise, the question becomes "Why did NUnit ignore
my attribute?" Come to think, that was your question.
No, you aren't abusing the framework at all. It took a lot of code to
make inherited attributes work and I wouldn't have written it if it were not
intended to be used. (The first implementation was done to allow
somebody to inherit ContextAttribute from TestFixture)
Now that we have that code, we can call it for any attribute we like.
Explicit is just not a place it's used, but it could be if you file the bug.
The NUnit 3.0 framework doesn't have this problem because the
loading and execution of tests is done by the framework assembly
itself. Consequently, we don't have to worry about loading tests
built against an older version of the framework. It's a simpler
approach and inheritance of attributes will "just work."
Charlie