static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NUnit Framework |
Fix Released
|
High
|
Charlie Poole | ||
NUnit V2 |
Fix Released
|
High
|
Charlie Poole |
Bug Description
NUnit 2.5.5. Even though TestFixtureSetU
To reproduce:
using System;
using NUnit.Framework;
public class TestBase
{
[TestFixtureSetUp]
public static void TestBaseTestFix
{
Console.
}
[TestFixtureTe
public static void TestBaseTestFix
{
Console.
}
}
public class TestDerived : TestBase
{
[TestFixtureSetUp]
public static void TestFixtureSetUp()
{
Console.
}
[TestFixtureTe
public static void TestFixtureTear
{
Console.
}
[Test]
public void TestMethod()
{
Console.
}
}
When you run this test, it only prints messages for the TestDerived class, not for TestBase.
tags: | added: confirm |
Changed in nunitv2: | |
importance: | Undecided → High |
milestone: | none → 2.5.6 |
status: | New → Triaged |
Changed in nunit-3.0: | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in nunitv2: | |
assignee: | nobody → Charlie Poole (charlie.poole) |
status: | Triaged → Fix Committed |
Changed in nunitv2: | |
status: | Fix Committed → Fix Released |
tags: | added: v2port |
tags: | removed: confirm |
Changed in nunit-3.0: | |
assignee: | nobody → Charlie Poole (charlie.poole) |
milestone: | none → 2.9.5 |
status: | Triaged → Fix Committed |
Changed in nunit-3.0: | |
status: | Fix Committed → Fix Released |
Hi Scott,
PFA a screenshot of a test method in the base class. The console does show
the print statements from the base class. In your example, there was no test
method in the class...the reason why the base class' fixtures were not
getting executed.
Looking at it, would you call this a bug?
Jv
On Tue, Jun 8, 2010 at 2:12 AM, Scott Hunter <email address hidden> wrote:
> Public bug reported: p/TestFixtureTe arDown methods tureSetUp( ) Out.WriteLine( "TestBase TestFixtureSetUp"); rDown] tureTearDown( ) Out.WriteLine( "TestBase TestFixtureTear Down"); Out.WriteLine( "TestDerived TestFixtureSetUp"); rDown] Down() Out.WriteLine( "TestDerived TestFixtureTear Down"); Out.WriteLine( "TestMethod" ); p/TestFixtureTe arDown methods in base classes are not /bugs.launchpad .net/bugs/ 590970 p/TestFixtureTe arDown methods can tureSetUp( ) Out.WriteLine( "TestBase TestFixtureSetUp"); rDown] tureTearDown( ) Out.WriteLine( "TestBase TestFixtureTear Down"); Out.WriteLine( "TestDerived TestFixtureSetUp"); rDown]
>
> NUnit 2.5.5. Even though TestFixtureSetU
> 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 TestBaseTestFix
> {
> Console.
> }
>
> [TestFixtureTea
> public static void TestBaseTestFix
> {
> Console.
> }
> }
>
> public class TestDerived : TestBase
> {
> [TestFixtureSetUp]
> public static void TestFixtureSetUp()
> {
> Console.
> }
>
> [TestFixtureTea
> public static void TestFixtureTear
> {
> Console.
> }
>
> [Test]
> public void TestMethod()
> {
> Console.
> }
> }
>
> When you run this test, it only prints messages for the TestDerived
> class, not for TestBase.
>
> ** Affects: nunitv2
> Importance: Undecided
> Status: New
>
> --
> static TestFixtureSetU
> run
> https:/
> 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 TestFixtureSetU
> 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 TestBaseTestFix
> {
> Console.
> }
>
> [TestFixtureTea
> public static void TestBaseTestFix
> {
> Console.
> }
> }
>
> public class TestDerived : TestBase
> {
> [TestFixtureSetUp]
> public static void TestFixtureSetUp()
> {
> Console.
> }
>
> [TestFixtureTea
> public ...