示例#1
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);
        }
示例#2
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);
            }
        }