From c2867ca21d9deb60f9553722e6e050a21fa0f406 Mon Sep 17 00:00:00 2001 From: twisterino Date: Thu, 10 Jul 2014 11:41:00 +0100 Subject: [PATCH 1/2] Prevent TearDown to swallow exceptions --- ...ctDependencyInjectionSpringContextTests.cs | 1 + ...endencyInjectionSpringContextTestsTests.cs | 71 ++++++++++++++----- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs index e2eaa67b..d3a444bb 100644 --- a/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs +++ b/src/Spring/Spring.Testing.NUnit/Testing/NUnit/AbstractDependencyInjectionSpringContextTests.cs @@ -349,6 +349,7 @@ namespace Spring.Testing.NUnit catch (Exception ex) { logger.Error("OnTearDown error", ex); + throw; } } diff --git a/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs b/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs index 654c9d31..c7833365 100644 --- a/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs +++ b/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs @@ -1,22 +1,24 @@ #region License -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -#endregion +#endregion + +using System; using NUnit.Framework; using Spring.Context; @@ -127,5 +129,42 @@ namespace Spring.Testing.NUnit Assert.AreNotSame(fixtureInstance.ApplicationContext, otherFixtureInstance.ApplicationContext); otherFixtureInstance.TearDown(); } - } + + private class TestAbstractDependencyInjectionSpringContextTestsExceptions : AbstractDependencyInjectionSpringContextTests + { + private static readonly string[] CONFIGLOCATIONS = new string[] { "assembly://Spring.Testing.NUnit.Tests/Spring.Testing.NUnit/TestApplicationContext.xml" }; + + public TestAbstractDependencyInjectionSpringContextTestsExceptions() + { } + + protected override string[] ConfigLocations + { + get { return CONFIGLOCATIONS; } + } + + protected override void OnSetUp() + { + throw new Exception("SetUp Exception"); + } + + protected override void OnTearDown() + { + throw new Exception("TearDown Expcetion"); + } + } + + [Test, ExpectedException] + public void ThrowsSetUpException() + { + var testFixture = new TestAbstractDependencyInjectionSpringContextTestsExceptions(); + testFixture.SetUp(); + } + + [Test, ExpectedException] + public void ThrowsTearDownException() + { + var testFixture = new TestAbstractDependencyInjectionSpringContextTestsExceptions(); + testFixture.TearDown(); + } + } } From be24957bb5baeec771ead82ab6e7e0367e61417f Mon Sep 17 00:00:00 2001 From: twisterino Date: Thu, 10 Jul 2014 11:50:51 +0100 Subject: [PATCH 2/2] Typo --- .../NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs b/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs index c7833365..014773d4 100644 --- a/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs +++ b/test/Spring/Spring.Testing.NUnit.Tests/Testing/NUnit/AbstractDependencyInjectionSpringContextTestsTests.cs @@ -149,7 +149,7 @@ namespace Spring.Testing.NUnit protected override void OnTearDown() { - throw new Exception("TearDown Expcetion"); + throw new Exception("TearDown Exception"); } }