private void Run(bool ok, TestFixture fixture, Test test, TestCase testCase, TestReporter reporter) { reporter.BeginTest(testCase); if (!ok) { reporter.EndTest(testCase, 0, TestCaseState.Failed); return; } bool setUpDone = false; TestCaseState runState = TestCaseState.Failed; try { fixture.SetUp(); setUpDone = true; testCase.Run(fixture, reporter); runState = TestCaseState.Success; } catch (System.Exception e) { Exception.Report(e, reporter); } TestCaseState state = TestCaseState.Failed; if (setUpDone) { try { fixture.TearDown(); state = runState; } catch (System.Exception e) { Exception.Report(e, reporter); } } reporter.EndTest(testCase, 0, state); }
private void Run(bool ok, string path, TestFixture fixture, Test test, TestCaseFilter filter, TestReporter reporter) { if (test.TestCases.Count > 0) { reporter.BeginSuite(test); foreach (var testCase in GetItemOrder(test.TestCases)) { if (filter.Match(path + "." + testCase.Name)) { Run(ok, fixture, test, testCase, reporter); } } reporter.EndSuite(test, 0); return; } reporter.BeginTest(test); if (!ok) { reporter.EndTest(test, 0, TestCaseState.Failed); return; } if (test.HasIgnoreAttribute) { reporter.Ignore(test.IgnoreMessage); reporter.EndTest(test, 0, TestCaseState.Ignored); return; } bool setUpDone = false; TestCaseState runState = TestCaseState.Failed; try { fixture.SetUp(); setUpDone = true; test.Run(fixture, reporter); runState = TestCaseState.Success; } catch (System.Exception e) { if (Exception.IsExpected(e, typeof(NUnit.Framework.IgnoreException).FullName)) { runState = TestCaseState.Ignored; reporter.Ignore(Exception.GetMessage(e)); } else { Exception.Report(e, reporter); } } TestCaseState state = TestCaseState.Failed; if (setUpDone) { try { fixture.TearDown(); state = runState; } catch (System.Exception e) { Exception.Report(e, reporter); } } reporter.EndTest(test, 0, state); }