public void TestStepBreakOnError(Verdict verdictOutput, object _condition) { // _condition arg cannot be a BreakCondition as BreakCondition is not public. BreakCondition condition = (BreakCondition)_condition; var l = new PlanRunCollectorListener(); TestPlan plan = new TestPlan(); var verdict = new VerdictStep { VerdictOutput = verdictOutput }; BreakConditionProperty.SetBreakCondition(verdict, condition); var verdict2 = new VerdictStep { VerdictOutput = Verdict.Pass }; plan.Steps.Add(verdict); plan.Steps.Add(verdict2); var run = plan.Execute(new[] { l }); Assert.AreEqual(verdictOutput, run.Verdict); Assert.AreEqual(1, l.StepRuns.Count); Assert.AreEqual(BreakCondition.Inherit, BreakConditionProperty.GetBreakCondition(verdict2)); var log = l.LogString; Assert.IsTrue(log.Contains("Break issued from")); }
public void EngineInheritedConditions(Verdict verdictOutput, EngineSettings.AbortTestPlanType abortTestPlanType, int runCount) { Verdict finalVerdict = verdictOutput; var prev = EngineSettings.Current.AbortTestPlan; try { EngineSettings.Current.AbortTestPlan = abortTestPlanType; var l = new PlanRunCollectorListener(); TestPlan plan = new TestPlan(); var verdict = new VerdictStep { VerdictOutput = verdictOutput }; BreakConditionProperty.SetBreakCondition(verdict, BreakCondition.Inherit); var verdict2 = new VerdictStep { VerdictOutput = Verdict.Pass }; plan.Steps.Add(verdict); plan.Steps.Add(verdict2); var run = plan.Execute(new[] { l }); Assert.AreEqual(finalVerdict, run.Verdict); Assert.AreEqual(runCount, l.StepRuns.Count); Assert.AreEqual(BreakCondition.Inherit, BreakConditionProperty.GetBreakCondition(verdict2)); } finally { EngineSettings.Current.AbortTestPlan = prev; } }
public void TestPlanBreakConditions() { var plan = new TestPlan(); var errorStep = new VerdictStep() { VerdictOutput = Verdict.Error }; var failStep = new VerdictStep() { VerdictOutput = Verdict.Fail }; var inconclusiveStep = new VerdictStep() { VerdictOutput = Verdict.Inconclusive }; var passStep = new VerdictStep() { VerdictOutput = Verdict.Pass }; plan.Steps.Add(errorStep); plan.Steps.Add(failStep); plan.Steps.Add(inconclusiveStep); plan.Steps.Add(passStep); var defaultValue = BreakConditionProperty.GetBreakCondition(plan); Assert.AreEqual(BreakCondition.Inherit, defaultValue); // break on fail, this means that 'passStep' will not get executed BreakConditionProperty.SetBreakCondition(plan, BreakCondition.BreakOnError); var col = new PlanRunCollectorListener(); plan.Execute(new [] { col }); Assert.AreEqual(1, col.StepRuns.Count); BreakConditionProperty.SetBreakCondition(plan, BreakCondition.BreakOnFail); col = new PlanRunCollectorListener(); plan.Execute(new [] { col }); Assert.AreEqual(2, col.StepRuns.Count); BreakConditionProperty.SetBreakCondition(plan, BreakCondition.BreakOnInconclusive); col = new PlanRunCollectorListener(); plan.Execute(new [] { col }); Assert.AreEqual(3, col.StepRuns.Count); BreakConditionProperty.SetBreakCondition(plan, 0); col = new PlanRunCollectorListener(); plan.Execute(new [] { col }); Assert.AreEqual(4, col.StepRuns.Count); }