示例#1
0
        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;
            }
        }
示例#2
0
        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"));
        }
示例#3
0
        public void RepeatWhileError(Verdict targetVerdict, RepeatStep.RepeatStepAction action)
        {
            var step = new PassThirdTime();

            BreakConditionProperty.SetBreakCondition(step, BreakCondition.BreakOnFail);

            var rpt = new RepeatStep()
            {
                Action        = action,
                TargetVerdict = targetVerdict,
                Retry         = true
            };

            rpt.TargetStep = rpt; // target self. The Repeat Loop will inherit the verdict.
            rpt.ChildTestSteps.Add(step);

            var plan = new TestPlan();

            plan.ChildTestSteps.Add(rpt);

            var run = plan.Execute();

            Assert.AreEqual(Verdict.Pass, run.Verdict);
            Assert.AreEqual(3, step.Iterations);
        }
示例#4
0
        public void RepeatUntilPass([Values(true, false)] bool retry)
        {
            var step = new PassThirdTime();

            BreakConditionProperty.SetBreakCondition(step, BreakCondition.BreakOnFail);

            var rpt = new RepeatStep()
            {
                Action        = RepeatStep.RepeatStepAction.Until,
                TargetStep    = step,
                TargetVerdict = Verdict.Pass,
                Retry         = retry
            };

            rpt.ChildTestSteps.Add(step);

            var plan = new TestPlan();

            plan.ChildTestSteps.Add(rpt);

            var run = plan.Execute();

            if (retry)
            {
                Assert.AreEqual(Verdict.Pass, run.Verdict);
                Assert.AreEqual(3, step.Iterations);
            }
            else
            {
                // break condition reached -> Error verdict.
                Assert.AreEqual(Verdict.Error, run.Verdict);
                Assert.AreEqual(1, step.Iterations);
            }
        }
示例#5
0
        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);
        }