public override void DoSetUp(TestResult suiteResult) { try { if (Fixture == null) { Fixture = Reflect.Construct(fixtureType); } if (this.fixtureSetUp != null) { Reflect.InvokeMethod(fixtureSetUp, Fixture); } IsSetUp = true; } catch (Exception ex) { // Error in TestFixtureSetUp causes the suite and // all contained suites to be ignored. // TODO: Change this to be a failure? NunitException nex = ex as NunitException; if (nex != null) { ex = nex.InnerException; } if (ex is NUnit.Framework.IgnoreException) { this.ShouldRun = false; suiteResult.NotRun(ex.Message); suiteResult.StackTrace = ex.StackTrace; this.IgnoreReason = ex.Message; } else { suiteResult.Failure(ex.Message, ex.StackTrace, true); } } finally { suiteResult.AssertCount = NUnit.Framework.Assert.Counter; } }
public override void DoTearDown(TestResult suiteResult) { if (this.ShouldRun) { try { IsSetUp = false; if (this.fixtureTearDown != null) { Reflect.InvokeMethod(fixtureTearDown, Fixture); } } catch (Exception ex) { // Error in TestFixtureTearDown causes the // suite to be marked as a failure, even if // all the contained tests passed. NunitException nex = ex as NunitException; if (nex != null) { ex = nex.InnerException; } suiteResult.Failure(ex.Message, ex.StackTrace); } finally { suiteResult.AssertCount += NUnit.Framework.Assert.Counter; } } if (this.IgnoreReason == FIXTURE_SETUP_FAILED) { this.ShouldRun = true; this.IgnoreReason = null; } }