Hi Kenneth,
I'll be on planes most of today, so I'll try to answer just based
on the email and do some experimenting tomorrow.
> > NUnit definitely queries for inherited TestFixture attributes.
> > If you have an example where it doesn't, you may have found a bug.
>
> It's quite easy to reproduce. You can follow what I described
> below or get them here:
> svn co
>
http://kennethxublogsource.googlecode.com/svn/trunk/Sandbox Sandbox
>
> Create two projects in a solution and add below classes:
>
> NUnitStuff project:
>
> [TestFixture]
> public abstract class ThirdPartyFixture
> {
> [Test] public void ThirdPartyTest() {}
> }
>
> NUnitStuff.Tests project:
>
> public abstract class AbstractFixture
> {
> [Test] public void TestOnAbstractFixture() { }
> [Test] public virtual void
> OverrideableTestOnAbstractFixture() { }
> }
> public class DerivedFixture : AbstractFixture
> {
> [Test] public void TestOnDerivedFixture() { }
> public override void OverrideableTestOnAbstractFixture() { }
> }
>
> Compile and use NUnit to run the NUnitStuff.Tests project,
> there are two evidences:
>
> 1. I don't get warning for test in the AbstractFixture.
I wouldn't expect it to. It's not in the assembly that NUnit
is scanning for tests. Separating such things into a different
assembly is a good strategy for avoiding the warning message.
> 2. NUnit didn't pick up test case: OverrideableTestOnAbstractFixture
I missed that we were talking about an overridden method. I'm
pretty sure NUnit does not have a test case for this.
Try putting a non-abstract test case in the base to see what
happens.
NUnit looks for inherited attributes for TestFixture, SetUp,
TearDown, TestFixtureSetUp and TestFixtureTearDown but *not*
for Test, TestCase, etc. Here's the reasoning:
TestFixture needs to have this to support inherited fixtures.
SetUp et al. is a historical thing: we used this approach
to allow easy transitioning from NUnit 1.11 to 2.0. It's
probably no longer needed - unless, of course, people have
discovered it and are using it for something else!
Tests have always been considered as invariant. Whether they
are specified in a base class or not is irrelevant - they
run because they are methods of the class being scanned
by NUnit and they always have the attribute defined where
the tests are defined.
The "usual" pattern is to use a template pattern for inherited
setup or test that needs to be tailored in the derived fixture.
I quoted "usual" because it's what I think is usual - I could
be wrong about how people are using this! However, it is the
pattern that currently works. :-)
Let's separate the problem we were discussing (inheritance
of abstract fixures) from this new one (overriding tests) and
see if we need a new feature. Obviously, it's doable if there
is a real use case for it but I wouldn't want to make things
more complicated without a reason.
Charlie
> > NUnit's own data providers on the individual parameters do
> not cause a
> > test fixture to be recognized - but they don't cause the
> method to be
> > recognized as a test either, so I guess that's a no-brainer.
> >
> > But the main exception is any attributes used by TestCaseBuilder or
> > DataProvider addins - unless the addin author also provides a
> > SuiteBuilder extension.
>
> I never wrote addin but this is good to know, thanks much.
> Cheers,
> Kenneth
>