public void ResultListeners() { resultListenerCrash[] crashers = new resultListenerCrash[] { new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.PlanRunStart }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.StepRunStart }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.Result }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.StepRunCompleted }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.PlanRunCompleted }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.Open }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.Close } }; TestPlan testplan = new TestPlan(); testplan.Steps.Add(new TestStepTest()); foreach (var crasher in crashers) { testplan.Execute(new IResultListener[] { crasher }); } }
public void ResultListenerAbortPlan() { // since the resultListenerCrash[] crashers = new resultListenerCrash[] { new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.PlanRunStart, AbortPlan = true }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.StepRunStart, AbortPlan = true }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.Result, AbortPlan = true }, new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.StepRunCompleted, AbortPlan = true }, // The plan cannot be aborted on PlanRunCompleted. The at that point it will be ignored. new resultListenerCrash { CrashResultPhase = resultListenerCrash.ResultPhase.PlanRunCompleted, AbortPlan = true } }; TestPlan testplan = new TestPlan(); testplan.Steps.Add(new TestStepTest()); foreach (var c in crashers) { c.FinalVerdict = Verdict.NotSet; var expectedVerdict = Verdict.Aborted; if (c.CrashResultPhase != resultListenerCrash.ResultPhase.PlanRunStart) { expectedVerdict = Verdict.Pass; } // Simply running the plan. var planrun = testplan.Execute(new IResultListener[] { c }); Assert.AreEqual(expectedVerdict, planrun.Verdict); Assert.AreEqual(expectedVerdict, c.FinalVerdict); // Test that it works in composite runs. // Here it's important that the abort does not spill into the next run. // Which is why the plan is run twice. testplan.Open(new IResultListener[] { c }); c.FinalVerdict = Verdict.NotSet; Assert.AreEqual(expectedVerdict, testplan.Execute(new IResultListener[] { c }).Verdict); Assert.AreEqual(expectedVerdict, c.FinalVerdict); c.CrashResultPhase = resultListenerCrash.ResultPhase.None; c.FinalVerdict = Verdict.NotSet; Assert.AreEqual(Verdict.Pass, testplan.Execute(new IResultListener[] { c }).Verdict); Assert.AreEqual(Verdict.Pass, c.FinalVerdict); testplan.Close(); } }