chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
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!
asked by vagif (19.4k points)

1 Answer

0 votes
I will forward the bug report and update this thread when it will be solved
answered by dhelper (11.9k points)
...