nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #00567
[Bug 590970] [NEW] static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
Public bug reported:
NUnit 2.5.5. Even though TestFixtureSetUp/TestFixtureTearDown methods
can be static, if they are defined them in a base class, they won't be
executed. From looking at the code, it seems like the problem is that
the reflection code to find fixture setup/teardown methods does not
search base classes.
To reproduce:
using System;
using NUnit.Framework;
public class TestBase
{
[TestFixtureSetUp]
public static void TestBaseTestFixtureSetUp()
{
Console.Out.WriteLine("TestBase TestFixtureSetUp");
}
[TestFixtureTearDown]
public static void TestBaseTestFixtureTearDown()
{
Console.Out.WriteLine("TestBase TestFixtureTearDown");
}
}
public class TestDerived : TestBase
{
[TestFixtureSetUp]
public static void TestFixtureSetUp()
{
Console.Out.WriteLine("TestDerived TestFixtureSetUp");
}
[TestFixtureTearDown]
public static void TestFixtureTearDown()
{
Console.Out.WriteLine("TestDerived TestFixtureTearDown");
}
[Test]
public void TestMethod()
{
Console.Out.WriteLine("TestMethod");
}
}
When you run this test, it only prints messages for the TestDerived
class, not for TestBase.
** Affects: nunitv2
Importance: Undecided
Status: New
--
static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
https://bugs.launchpad.net/bugs/590970
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
Status in NUnit V2 Test Framework: New
Bug description:
NUnit 2.5.5. Even though TestFixtureSetUp/TestFixtureTearDown methods can be static, if they are defined them in a base class, they won't be executed. From looking at the code, it seems like the problem is that the reflection code to find fixture setup/teardown methods does not search base classes.
To reproduce:
using System;
using NUnit.Framework;
public class TestBase
{
[TestFixtureSetUp]
public static void TestBaseTestFixtureSetUp()
{
Console.Out.WriteLine("TestBase TestFixtureSetUp");
}
[TestFixtureTearDown]
public static void TestBaseTestFixtureTearDown()
{
Console.Out.WriteLine("TestBase TestFixtureTearDown");
}
}
public class TestDerived : TestBase
{
[TestFixtureSetUp]
public static void TestFixtureSetUp()
{
Console.Out.WriteLine("TestDerived TestFixtureSetUp");
}
[TestFixtureTearDown]
public static void TestFixtureTearDown()
{
Console.Out.WriteLine("TestDerived TestFixtureTearDown");
}
[Test]
public void TestMethod()
{
Console.Out.WriteLine("TestMethod");
}
}
When you run this test, it only prints messages for the TestDerived class, not for TestBase.
Follow ups
-
[Bug 590970]
From: Jv, 2011-12-22
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-31
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-27
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Launchpad Bug Tracker, 2010-07-27
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-26
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-25
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-25
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Launchpad Bug Tracker, 2010-07-20
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-20
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-10
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Charlie Poole, 2010-07-10
-
[Bug 590970] Re: static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Scott Hunter, 2010-06-08
-
Re: [Bug 590970] [NEW] static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Jv, 2010-06-08
-
[Bug 590970] [NEW] static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
From: Scott Hunter, 2010-06-07
References