Activity log for bug #1233141

Date Who What changed Old value New value Message
2013-09-30 12:40:59 Birgit Vera Schmidt bug added bug
2013-09-30 19:59:34 Charlie Poole nunitv2: status New Triaged
2013-09-30 19:59:38 Charlie Poole nunitv2: importance Undecided Medium
2013-10-05 23:24:58 Charlie Poole affects nunitv2 nunit-3.0
2013-10-20 00:44:04 Charlie Poole description (NUnit 2.5.10.11092 wit GUI runner) The behaviour of TearDown and TestFixtureTearDown in case of an Exception in the corresponding SetUp is described in the same way, but behaves differently. Decription of TearDown: So long as any SetUp method runs without error, the TearDown method is guaranteed to run. It will not run if a SetUp method fails or throws an exception. Description of TestFixtureTearDown: So long as any TestFixtureSetUp method runs without error, the TestFixtureTearDown method is guaranteed to run. It will not run if a TestFixtureSetUp method fails or throws an exception. I have the following two very simple classes: ============================================================== [TestFixture] public class Base { [TestFixtureSetUp] public void TestFixtureSetUp() { Console.WriteLine("Running TestFixtureSetUp Base"); } [SetUp] public void SetUp() { Console.WriteLine("Running SetUp Base"); } [Test] public void TestBase() { Console.WriteLine("Running Test Base"); } [TearDown] public void TearDown() { Console.WriteLine("Running TearDown Base"); } [TestFixtureTearDown] public void TestFixtureTearDown() { Console.WriteLine("Running TestFixtureTearDown Base"); } } ============================================================== [TestFixture] public class Derived : Base { [TestFixtureSetUp] public new void TestFixtureSetUp() { Console.WriteLine("Running TestFixtureSetUp Derived"); } [SetUp] public new void SetUp() { Console.WriteLine("Running SetUp Derived"); } [Test] public void TestDerived() { Console.WriteLine("Running Test Derived"); } [TearDown] public new void TearDown() { Console.WriteLine("Running TearDown Derived"); } [TestFixtureTearDown] public new void TestFixtureTearDown() { Console.WriteLine("Running TestFixtureTearDown Derived"); } } ============================================================== Executing TestDerived works as expected: ============================================================== Running TestFixtureSetUp Base Running TestFixtureSetUp Derived Running SetUp Base Running SetUp Derived Running Test Derived Running TearDown Derived Running TearDown Base Running TestFixtureTearDown Derived Running TestFixtureTearDown Base ============================================================== Now I introduce an Exception in SetUp of Base: ============================================================== [SetUp] public void SetUp() { Console.WriteLine("Running SetUp Base"); throw new Exception("Exception in SetUp Base"); } ============================================================== Executing TestDerived now gives this output: ============================================================== Running TestFixtureSetUp Base Running TestFixtureSetUp Derived Running SetUp Base Running TearDown Derived Running TearDown Base Test 'Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Derived.TestDerived' failed: SetUp : System.Exception : Exception in SetUp Base Base.cs(18,0): at Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Base.SetUp() Running TestFixtureTearDown Derived Running TestFixtureTearDown Base ============================================================== Since the behaviour of TearDown and TestFixtureTearDown in case of an exception in the corresponding SetUp function is described the same way, word by word, I would expect that if there was an Exception in TestFixtureSetUp Base, then also both TestFixtureTearDown Derived and TestFixtureTearDown Base will be called. However, if I remove the Exception from SetUp Base again and instead add one to TestFixtureSetUp Base... ============================================================== [TestFixtureSetUp] public void TestFixtureSetUp() { Console.WriteLine("Running TestFixtureSetUp Base"); throw new Exception("Exception in TestFixtureSetUp Base"); } ============================================================== ... then running TestDerived gives the following output: ============================================================== Running TestFixtureSetUp Base Test 'Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Derived.TestDerived' failed: TestFixtureSetUp failed in Derived TestFixture failed: SetUp : System.Exception : Exception in TestFixtureSetUp Base at Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Base.TestFixtureSetUp() in D:\git\TestAutomationFramework_V2013\Projects\Infrastructure\UnitTests\TestDriver\Base.cs:line 13 ============================================================== (See also https://groups.google.com/forum/#!topic/nunit-discuss/6KY1yeJNh5U ) Issue now tracked at https://github.com/nunit/nunit-framework/issues/32 (NUnit 2.5.10.11092 wit GUI runner) The behaviour of TearDown and TestFixtureTearDown in case of an Exception in the corresponding SetUp is described in the same way, but behaves differently. Decription of TearDown: So long as any SetUp method runs without error, the TearDown method is guaranteed to run. It will not run if a SetUp method fails or throws an exception. Description of TestFixtureTearDown: So long as any TestFixtureSetUp method runs without error, the TestFixtureTearDown method is guaranteed to run. It will not run if a TestFixtureSetUp method fails or throws an exception. I have the following two very simple classes: ==============================================================   [TestFixture]   public class Base   {     [TestFixtureSetUp]     public void TestFixtureSetUp()     {       Console.WriteLine("Running TestFixtureSetUp Base");     }     [SetUp]     public void SetUp()     {       Console.WriteLine("Running SetUp Base");     }     [Test]     public void TestBase()     {       Console.WriteLine("Running Test Base");     }     [TearDown]     public void TearDown()     {       Console.WriteLine("Running TearDown Base");     }     [TestFixtureTearDown]     public void TestFixtureTearDown()     {       Console.WriteLine("Running TestFixtureTearDown Base");     }   } ==============================================================   [TestFixture]   public class Derived : Base   {     [TestFixtureSetUp]     public new void TestFixtureSetUp()     {       Console.WriteLine("Running TestFixtureSetUp Derived");     }     [SetUp]     public new void SetUp()     {       Console.WriteLine("Running SetUp Derived");     }     [Test]     public void TestDerived()     {       Console.WriteLine("Running Test Derived");     }     [TearDown]     public new void TearDown()     {       Console.WriteLine("Running TearDown Derived");     }     [TestFixtureTearDown]     public new void TestFixtureTearDown()     {       Console.WriteLine("Running TestFixtureTearDown Derived");     }   } ============================================================== Executing TestDerived works as expected: ============================================================== Running TestFixtureSetUp Base Running TestFixtureSetUp Derived Running SetUp Base Running SetUp Derived Running Test Derived Running TearDown Derived Running TearDown Base Running TestFixtureTearDown Derived Running TestFixtureTearDown Base ============================================================== Now I introduce an Exception in SetUp of Base: ==============================================================     [SetUp]     public void SetUp()     {       Console.WriteLine("Running SetUp Base");       throw new Exception("Exception in SetUp Base");     } ============================================================== Executing TestDerived now gives this output: ============================================================== Running TestFixtureSetUp Base Running TestFixtureSetUp Derived Running SetUp Base Running TearDown Derived Running TearDown Base Test 'Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Derived.TestDerived' failed: SetUp : System.Exception : Exception in SetUp Base     Base.cs(18,0): at Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Base.SetUp() Running TestFixtureTearDown Derived Running TestFixtureTearDown Base ============================================================== Since the behaviour of TearDown and TestFixtureTearDown in case of an exception in the corresponding SetUp function is described the same way, word by word, I would expect that if there was an Exception in TestFixtureSetUp Base, then also both TestFixtureTearDown Derived and TestFixtureTearDown Base will be called. However, if I remove the Exception from SetUp Base again and instead add one to TestFixtureSetUp Base... ==============================================================     [TestFixtureSetUp]     public void TestFixtureSetUp()     {       Console.WriteLine("Running TestFixtureSetUp Base");       throw new Exception("Exception in TestFixtureSetUp Base");     } ============================================================== ... then running TestDerived gives the following output: ============================================================== Running TestFixtureSetUp Base Test 'Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Derived.TestDerived' failed: TestFixtureSetUp failed in Derived TestFixture failed: SetUp : System.Exception : Exception in TestFixtureSetUp Base    at Avl.TestAutomationFramework.Infrastructure.UnitTests.TestDriver.Base.TestFixtureSetUp() in D:\git\TestAutomationFramework_V2013\Projects\Infrastructure\UnitTests\TestDriver\Base.cs:line 13 ============================================================== (See also https://groups.google.com/forum/#!topic/nunit-discuss/6KY1yeJNh5U )
2013-10-20 00:44:12 Charlie Poole tags github