Re: Latest NUnit not running superclass setup/teardown in2.4.7?

Doug Mayer <[email protected]> Thu, 03 Jul 2008 16:48:49 -0500
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
Here is an example of what I'm trying to do:

    public class ActiveRecordModelTestBase
    {
        [TestFixtureSetUp]
        public virtual void FixtureInit()
        {
            InitFramework();
        }

        [SetUp]
        public virtual void Init()
        {
            PrepareSchema();

            CreateScope();
        }

        [TearDown]
        public virtual void Terminate()
        {
            DisposeScope();

            DropSchema();
        }

        [TestFixtureTearDown]
        public virtual void FixtureTerminate()
        {
        }

        // ... non-attributed methods ...
    }

    public abstract class InfrastructureModelTestBase : 
ActiveRecordModelTestBase
    {
        // NO methods with attributes, only a view overrides for 
PrepareSchema(), etc
    }

    [TestFixture]
    public class UserTestCase : InfrastructureModelTestBase
    {
        // Only tests marked with [Test] attributes, NO setup/teardown 
attributes
    }
...

ActiveRecordModelTestBase is in one assembly, 
InfrastructureModelTestBase and UserTestCase are in another.  When I run 
any tests in UserTestCase, it never even hits the methods defined in 
ActiveRecordModelTestBase.  I got it working by rolling back to 2.4.6, 
so perhaps it was something introduced in 2.4.7?

Thanks!
Doug

Charlie Poole wrote:
> Provided that the BaseClass has a method marked as
> [SetUp] it should be run unless you do something
> in a derived class to hide it.  Can you provide
> a complete example?
>
> Charlie
>
>   
>> -----Original Message-----
>> From: [email protected] 
>> [mailto:[email protected]] On Behalf 
>> Of Doug Mayer
>> Sent: Thursday, July 03, 2008 12:56 PM
>> To: [email protected]
>> Subject: [Nunit-users] Latest NUnit not running superclass 
>> setup/teardown in2.4.7?
>>
>> I'm having trouble getting something like this to work with 
>> NUnit 2.4.7, but it works fine in 2.4.6:
>>
>> class BaseClass {
>>      // fixture and test set-up and tear-down }
>>
>> class BaseSubClass : BaseClass {
>> }
>>
>> [TestFixture]
>> class MyTestCase : BaseSubClass {
>> }
>>
>>
>> The tests in MyTestCase won't do any of the setup/teardown 
>> (both fixture and per-test) defined in the BaseClass.  Is 
>> this a bug or an intended breaking change?  Has anyone else seen this?
>>
>> Thanks!
>> Doug
>>
>> --------------------------------------------------------------
>> -----------
>> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
>> Studies have shown that voting for your favorite open source 
>> project, along with a healthy diet, reduces your potential 
>> for chronic lameness and boredom. Vote Now at 
>> http://www.sourceforge.net/community/cca08
>> _______________________________________________
>> Nunit-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/nunit-users
>>
>>     
>
>
>   

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08