This bug was reported before, but it is still present in the latest Isolator version and occurs when NUnit 2.5 is used.
Here's the code that does not use Isolator (Isolated attribute is commented out):
[TestFixture]
//[Isolated]
public class TestBase
{
[SetUp]
public virtual void SetUp()
{
Console.WriteLine("TestBase.SetUp");
}
}
[TestFixture]
//[Isolated]
public class TestClass : TestBase
{
[SetUp]
public override void SetUp()
{
base.SetUp();
Console.WriteLine("TestClass.SetUp");
}
[Test]
public void Test()
{
Console.WriteLine("TestClass.Test");
}
}
The output:
TestBase.SetUp
TestClass.SetUp
TestClass.Test
Now we enable Isolated attribute on a base class:
[TestFixture]
[Isolated]
public class TestBase
{
[SetUp]
public virtual void SetUp()
{
Console.WriteLine("TestBase.SetUp");
}
}
The output changes:
TestBase.SetUp
TestClass.SetUp
TestClass.SetUp
TestClass.Test
As you can see, TestClass.SetUp is executed twice, which is wrong.
But things get even worse. Enable Isolated attribute on a derived class:
[TestFixture]
[Isolated]
public class TestClass : TestBase
{
[SetUp]
public override void SetUp()
{
base.SetUp();
Console.WriteLine("TestClass.SetUp");
}
[Test]
public void Test()
{
Console.WriteLine("TestClass.Test");
}
}
Execute test. Bang! Stack overflow!