예제 #1
0
        public void RunCompositeFollowedByRun()
        {
            TestPlan target = getTestTestPlan();

            target.Open();
            target.Execute();
            target.Close();
            Log.Flush();
            TestTraceListener trace2 = new TestTraceListener();

            Log.AddListener(trace2);
            target.Open();
            target.Execute();
            target.Close();
            Log.RemoveListener(trace2);
            TestTraceListener trace1 = new TestTraceListener();

            Log.AddListener(trace1);
            target.Execute();
            Log.RemoveListener(trace1);

            string allLog1 = trace1.allLog.ToString();
            string allLog2 = trace2.allLog.ToString();

            string[] log1Lines = filterLog(allLog1);
            string[] log2Lines = filterLog(allLog2);


            Assert.AreEqual(log1Lines.Count() + 2, log2Lines.Count(), allLog2);
            for (int i = 0; i < log1Lines.Length; i++)
            {
                CollectionAssert.Contains(log2Lines, log1Lines[i]);
            }
        }
예제 #2
0
        public void RunCompositeStartTime()
        {
            PlanRunCollectorListener listener = new PlanRunCollectorListener();

            ResultSettings.Current.Add(listener);

            TestTraceListener trace = new TestTraceListener();

            Log.AddListener(trace);

            TestPlan target = getTestTestPlan();

            target.Open();
            target.Execute();
            listener.StepRuns.Clear();
            target.Execute();
            target.Close();

            Log.RemoveListener(trace);

            ResultSettings.Current.Remove(listener);

            Assert.AreEqual(2, listener.PlanRuns.Select(run => run.StartTimeStamp).Distinct().Count());
            Assert.AreEqual(1, listener.StepRuns.Count());
        }
예제 #3
0
        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();
            }
        }
예제 #4
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);
        }
예제 #5
0
        public void RunSweep([Values(true, false)] bool acrossRuns, [Values(true, false)] bool allEnabled)
        {
            var tp = new TestPlan();

            var sl = new SweepLoop()
            {
                CrossPlan = acrossRuns ? SweepLoop.SweepBehaviour.Across_Runs : SweepLoop.SweepBehaviour.Within_Run
            };

            var ds = new SweepTestStep();

            sl.ChildTestSteps.Add(ds);
            sl.SweepParameters.Add(new SweepParam(new[] { TypeData.GetTypeData(ds).GetMember("SweepProp") }, 2, 3, 5, 7));
            sl.EnabledRows = new bool[] { true, allEnabled, true, true };

            tp.ChildTestSteps.Add(sl);

            using (var st = new MemoryStream())
            {
                tp.Save(st);
                st.Seek(0, 0);
                tp = TestPlan.Load(st, tp.Path);
            }
            ds = tp.ChildTestSteps[0].ChildTestSteps[0] as SweepTestStep;
            if (acrossRuns)
            {
                foreach (var rowEnabled in sl.EnabledRows)
                {
                    if (rowEnabled)
                    {
                        var pr = tp.Execute();
                        Assert.IsFalse(pr.FailedToStart);
                        Assert.AreEqual(Verdict.NotSet, pr.Verdict);
                    }
                }
            }
            else
            {
                var pr = tp.Execute();
                Assert.IsFalse(pr.FailedToStart);
            }
            if (allEnabled)
            {
                Assert.AreEqual(17, ds.Value);
            }
            else
            {
                Assert.AreEqual(14, ds.Value);
            }
        }
예제 #6
0
        public void ResourceStepRefTest()
        {
            InstrumentSettings.Current.Clear();
            ResultSettings.Current.Clear();

            InstrumentSettings.Current.Add(new CircDummyInst());

            var step1 = new ResourceStep()
            {
                Inst = InstrumentSettings.Current[0]
            };
            var step2 = new ResourceStep()
            {
                Inst = step1
            };

            var tp = new TestPlan();

            tp.ChildTestSteps.Add(step1);
            tp.ChildTestSteps.Add(step2);

            var run = tp.Execute();

            Assert.AreEqual(2, run.StepsWithPrePlanRun.Count);
            Assert.IsFalse(run.FailedToStart);
        }
예제 #7
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);
            }
        }
예제 #8
0
        public void RunHierarchical2()
        {
            TestPlan testplan = new TestPlan();

            var grandParent = new SequenceStep();

            testplan.Steps.Add(grandParent);

            var parent = new SequenceStep();

            grandParent.ChildTestSteps.Add(parent);

            var child1 = new WithEvents();

            parent.ChildTestSteps.Add(child1);

            var child2 = new WithEvents();

            parent.ChildTestSteps.Add(child2);

            testplan.BreakOffered += _testplan_TestStepPaused;

            _pausedDetectedCount   = 0;
            _startingDetectedCount = 0;

            testplan.Execute();

            // Since only two of the steps are with events, we get
            // _starting = total
            // _pausedCount = 2;
            var test = TotalEnabledStepsInTestPlan(testplan);

            Assert.IsTrue(_startingDetectedCount == TotalEnabledStepsInTestPlan(testplan));
            Assert.IsTrue(_pausedDetectedCount == 2);
        }
예제 #9
0
        public void TestNameFormat2()
        {
            var plan   = new TestPlan();
            var repeat = new RepeatStep {
                Count = 10, Action = RepeatStep.RepeatStepAction.Fixed_Count
            };

            repeat.Name = "Repeat : {Iteration}";
            plan.ChildTestSteps.Add(repeat);
            var logStep = new LogStep();

            repeat.ChildTestSteps.Add(logStep);
            var log = new TestTraceListener();

            Log.AddListener(log);
            var run = plan.Execute();

            Assert.AreEqual(Verdict.NotSet, run.Verdict);
            Log.RemoveListener(log);
            var thelog = log.GetLog();

            for (int i = 0; i < repeat.Count; i++)
            {
                var str = string.Format("Repeat : {0} of {1}", i, repeat.Count);
                Assert.IsTrue(thelog.Contains(str));
            }
        }
예제 #10
0
        public void ContinueLoop()
        {
            var sequence = new SequenceStep();
            var verdict1 = new VerdictStep {
                VerdictOutput = Verdict.Pass
            };
            var ifstep = new IfStep()
            {
                Action = IfStep.IfStepAction.ContinueLoop, TargetVerdict = Verdict.Pass
            };

            ifstep.InputVerdict.Property = TypeData.GetTypeData(verdict1).GetMember(nameof(VerdictStep.Verdict));
            ifstep.InputVerdict.Step     = verdict1;
            var verdict2 = new VerdictStep()
            {
                VerdictOutput = Verdict.Fail
            };

            sequence.ChildTestSteps.Add(verdict1);
            sequence.ChildTestSteps.Add(ifstep);   // instructed to skip the last verdict step
            sequence.ChildTestSteps.Add(verdict2); // if this step runs the plan will get the verdict 'fail'.
            var plan = new TestPlan();

            plan.ChildTestSteps.Add(sequence);

            var run = plan.Execute();

            Assert.AreEqual(Verdict.Pass, run.Verdict);
        }
예제 #11
0
        public void BreakAbortStepRunNull()
        {
            TestPlan     testPlan = new TestPlan();
            SequenceStep step1    = new SequenceStep();
            SequenceStep step2    = new SequenceStep();
            SequenceStep step3    = new SequenceStep();

            testPlan.Steps.Add(step1);
            testPlan.Steps.Add(step2);
            testPlan.Steps.Add(step3);

            TapThread.WithNewContext(() =>
            {
                var planThread         = TapThread.Current;
                testPlan.BreakOffered += (s, e) => planThread.Abort();
                testPlan.Execute();
                Assert.IsTrue(TapThread.Current.AbortToken.IsCancellationRequested);
            });
            Assert.IsFalse(TapThread.Current.AbortToken.IsCancellationRequested);

            foreach (var step in testPlan.Steps)
            {
                Assert.IsNull(step.StepRun);
            }
        }
예제 #12
0
        public void RunLoop()
        {
            TestPlan testplan = new TestPlan();

            var  grandParent = new RepeatStep();
            uint loopCount   = 7;

            grandParent.Count  = loopCount;
            grandParent.Action = RepeatStep.RepeatStepAction.Fixed_Count;
            testplan.Steps.Add(grandParent);

            var parent = new WithEvents();

            grandParent.ChildTestSteps.Add(parent);

            testplan.BreakOffered += _testplan_TestStepPaused;

            _pausedDetectedCount   = 0;
            _startingDetectedCount = 0;

            testplan.Execute();

            //We will actually have loopCount + 1 starts.
            // We get a start for each of the loops around "withevents steps", plus one for the outer loop "FixedCountLoop" step
            Assert.AreEqual(loopCount + 1, _startingDetectedCount, "StartingDetectedCount");

            //Since fixed count loop does NOT have a pause, it will not count in the pause count.
            Assert.AreEqual(loopCount, _pausedDetectedCount, "PausedDetectedCount");
        }
예제 #13
0
        public void ResultTableName()
        {
            var      rl = new ResultValidator();
            TestPlan tp = new TestPlan();

            tp.ChildTestSteps.Add(new DelegateTestStep
            {
                RunAction = (r) =>
                {
                    r.Publish(new TestCls <double> {
                        X = 1.0
                    });
                    r.Publish(new TestCls <double> .TestCls2 <int> {
                        X = 1.0, Y = 1
                    });
                }
            });
            var run = tp.Execute(new[] { rl });

            Assert.AreEqual("TestCls`1", rl.Results.First().Name);
            Assert.AreEqual("TestCls2`1", rl.Results.Last().Name);
            bool anyNullGroup = run.Parameters.Any(x => x.Group == null);

            Assert.IsFalse(anyNullGroup);
        }
예제 #14
0
        public void SimpleTestLazyManager()
        {
            EngineSettings.Current.ResourceManagerType = new LazyResourceManager();
            IInstrument instr1 = new SomeInstrument()
            {
                Name = "INSTR1"
            };
            IInstrument instr2 = new SomeInstrument()
            {
                Name = "INSTR2"
            };

            InstrumentSettings.Current.Add(instr1);
            InstrumentSettings.Current.Add(instr2);
            TestPlan plan = new TestPlan();

            plan.Steps.Add(new InstrumentTestStep()
            {
                Instrument = instr1
            });
            plan.Steps.Add(new InstrumentTestStep()
            {
                Instrument = instr2
            });
            UnitTestingLockManager.Enable();
            plan.Execute();
            UnitTestingLockManager.Disable();
            Assert.AreEqual(2, UnitTestingLockManager.BeforeOpenArgs.Count(), "BeforeOpen hook called an unexpected number of times.");
            Assert.AreEqual(1, UnitTestingLockManager.BeforeOpenArgs.First().Count(), "Resources list contain an unexpected number of items.");
            Assert.AreEqual(instr1, UnitTestingLockManager.BeforeOpenArgs.First().First().Resource, "ResourceReference has unexpected Resource.");
        }
예제 #15
0
        public void DependentResourceNull()
        {
            EngineSettings.Current.ResourceManagerType = new ResourceTaskManager();
            InstrumentSettings.Current.Clear();
            try
            {
                var inst0 = new CircInst();
                InstrumentSettings.Current.Add(inst0);
                InstrumentSettings.Current.Add(new CircInst {
                    inst = null
                });
                InstrumentSettings.Current.Add(new CircInst {
                    inst = InstrumentSettings.Current[1]
                });
                inst0.inst = InstrumentSettings.Current[2];

                TestPlan plan  = new TestPlan();
                var      step1 = new CircTestStep()
                {
                    Instrument = inst0
                };

                plan.ChildTestSteps.Add(step1);

                var planRun = plan.Execute();
                Assert.IsTrue(planRun.FailedToStart);
                Assert.AreEqual(Verdict.Error, planRun.Verdict);
            }
            finally
            {
                InstrumentSettings.Current.Clear();
            }
        }
예제 #16
0
        public void CircularResource2Reference()
        {
            EngineSettings.Current.ResourceManagerType = new ResourceTaskManager();
            InstrumentSettings.Current.Clear();
            try
            {
                var inst0 = new CircInst();
                InstrumentSettings.Current.Add(inst0);
                inst0.inst = InstrumentSettings.Current[0];

                TestPlan plan  = new TestPlan();
                var      step1 = new CircTestStep()
                {
                    Instrument = inst0
                };

                plan.ChildTestSteps.Add(step1);

                var planRun = plan.Execute();
                Assert.AreEqual(Verdict.Error, planRun.Verdict);
            }
            finally
            {
                InstrumentSettings.Current.Clear();
            }
        }
예제 #17
0
        public void SimpleResourceNullPropertyTest()
        {
            // Just test that we can run a plan with a null resource, if the null is repaced with an actual instance by ILockManager.BeforeOpen()
            EngineSettings.Current.ResourceManagerType = new LazyResourceManager();
            IInstrument instr1 = new SomeInstrument()
            {
                Name = "INSTR1"
            };

            InstrumentSettings.Current.Add(instr1);
            TestPlan  plan  = new TestPlan();
            ITestStep step1 = new InstrumentTestStep()
            {
                Instrument = null
            };

            plan.Steps.Add(step1);
            UnitTestingLockManager.Enable();
            UnitTestingLockManager.BeforeOpenEffect = SetNullResources;
            var run = plan.Execute();

            UnitTestingLockManager.Disable();

            Assert.IsFalse(run.FailedToStart, "Plan run failed.");
            Assert.AreEqual(Verdict.NotSet, run.Verdict);
            Assert.AreEqual(1, UnitTestingLockManager.BeforeOpenArgs.Count(), "BeforeOpen hook called an unexpected number of times.");

            IEnumerable <IResourceReferences> arg1 = UnitTestingLockManager.BeforeOpenArgs.First();

            Assert.AreEqual(1, arg1.Count(), "Resources list contain an unexpected number of items.");
        }
예제 #18
0
        public void TestResourceReference()
        {
            // Loop seems to provoke a race condition in test plan execution
            for (int i = 0; i < 10; i++)
            {
                EngineSettings.Current.ToString();
                var step = new OpenTap.Plugins.BasicSteps.SweepLoop();

                var theDuts  = Enumerable.Range(0, 10).Select(number => new IsOpenedDut()).ToArray();
                var otherdut = new IsOpenedDut();

                step.ChildTestSteps.Add(new IsOpenUsedTestStep()
                {
                    Resource = new IsOpenedDut(), Resource2 = otherdut, Resource3 = new [] { new IsOpenedDut() }
                });
                step.SweepParameters.Add(new OpenTap.Plugins.BasicSteps.SweepParam(new IMemberData[] { TypeData.FromType(typeof(IsOpenUsedTestStep)).GetMember("Resource") }, theDuts));
                var plan = new TestPlan();
                plan.PrintTestPlanRunSummary = true;
                plan.ChildTestSteps.Add(step);
                var rlistener = new PlanRunCollectorListener();
                var planRun   = plan.Execute(new IResultListener[] { rlistener });
                Assert.AreEqual(theDuts.Length + 1, rlistener.StepRuns.Count);
                Assert.IsTrue(planRun.Verdict == Verdict.NotSet);
                Assert.IsTrue(theDuts.All(dut => dut.IsClosed && dut.IsOpened && dut.IsUsed));
            }
        }
예제 #19
0
        public void IgnoredResource()
        {
            InstrumentSettings.Current.Clear();
            ResultSettings.Current.Clear();

            var inst = new CircDummyInst();

            InstrumentSettings.Current.Add(inst);
            var listener = new EngineUnitTestUtils.TestTraceListener();

            Log.AddListener(listener);
            var tp = new TestPlan();

            tp.ChildTestSteps.Add(new IgnoredResourceStep()
            {
                resource = inst
            });
            var run = tp.Execute();

            Log.RemoveListener(listener);

            Assert.IsFalse(run.FailedToStart);
            Assert.AreEqual(1, run.StepsWithPrePlanRun.Count);
            Assert.AreEqual(Verdict.Pass, run.Verdict, listener.GetLog());
        }
예제 #20
0
        public void TestMethodResourceSettingNullReference()
        {
            TestTraceListener tapTraceListener = new TestTraceListener();
            DummyDut          device           = new DummyDut();

            try
            {
                Log.AddListener(tapTraceListener);
                DutSettings.Current.Add(device);

                // this works
                var testPlan = new TestPlan();
                var step     = new DummyInstrumentAndDutStep()
                {
                    Device = device, Instrument = null
                };
                testPlan.ChildTestSteps.Add(step);
                var run = testPlan.Execute();

                Assert.AreEqual(Verdict.Error, run.Verdict);
                tapTraceListener.ExpectWarnings("TestPlan aborted.");
                tapTraceListener.ExpectErrors(
                    $"Resource setting {nameof(DummyInstrumentAndDutStep.Instrument)} not set on step {nameof(DummyInstrumentAndDutStep)}. Please configure or disable step.");
            }
            finally
            {
                tapTraceListener.Flush();
                Log.RemoveListener(tapTraceListener);
                DutSettings.Current.Remove(device);
            }
        }
예제 #21
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);
        }
예제 #22
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;
            }
        }
예제 #23
0
        public void RunHierarchical()
        {
            TestPlan testplan = new TestPlan();

            var grandParent = new WithEvents();

            testplan.Steps.Add(grandParent);

            var parent = new WithEvents();

            grandParent.ChildTestSteps.Add(parent);

            var child1 = new WithEvents();

            parent.ChildTestSteps.Add(child1);

            var child2 = new WithEvents();

            parent.ChildTestSteps.Add(child2);

            testplan.BreakOffered += _testplan_TestStepPaused;

            _pausedDetectedCount   = 0;
            _startingDetectedCount = 0;

            testplan.Execute();

            // Since ALL the steps are of type WithEvents, we continue to get
            // a pausedcount = startingCount = totalcount.
            Assert.IsTrue(_startingDetectedCount == TotalEnabledStepsInTestPlan(testplan));
            Assert.IsTrue(_pausedDetectedCount == TotalEnabledStepsInTestPlan(testplan));
        }
예제 #24
0
        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 });
            }
        }
예제 #25
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"));
        }
예제 #26
0
        public void RepeatWithReferenceOutsideStep()
        {
            var      stream = File.OpenRead("TestTestPlans/whiletest.TapPlan");
            TestPlan plan   = (TestPlan) new TapSerializer().Deserialize(stream, type: TypeData.FromType(typeof(TestPlan)));
            var      run    = plan.Execute();

            Assert.AreEqual(Verdict.Pass, run.Verdict);
        }
예제 #27
0
        public void VersionProperties()
        {
            TestPlan tp = new TestPlan();

            tp.ChildTestSteps.Add(new Plugins.BasicSteps.DelayStep());
            var tpr = tp.Execute();

            Assert.IsTrue(tpr.Parameters.Any(p => p.Group == "Version" && p.Name == "OpenTap"), "No engine version parameter found");
        }
예제 #28
0
 public static void Test()
 {
     Log.Write("starting to executing test plan automatically.");
     foreach (string testplan in Directory.GetFiles(TestPlanConfigFilePath))
     {
         TestPlan tp = null;
         try
         {
             tp = new TestPlan(testplan, ApplicationConfigFilePath,
                               TestCaseConfigFilePath, WebDriversFilePath, TempFilePath, EmailFrom, EmailFromPassword,
                               EmailTo, CcTo, EmailHost, int.Parse(EmailPort), EnableSsl, null);
         }
         catch (Exception ex)
         {
             Log.Write("Test cannot be executed, the reason is: " + ex.Message);
         }
         tp.TestingProgressChange += tp_TestingProgressChange;
         if (RestartApplicationWhenError && ContinueWhenError)
         {
             tp.TestCaseOnError = (cmd, isLast) =>
             {
                 if (isLast)
                 {
                     return;
                 }
                 //DesktopAppCommand command = cmd as DesktopAppCommand;
                 //if (command != null)
                 //{
                 //    //RestoreDb();
                 //    command.Restart();
                 //}
             };
             tp.TestCaseOnError = (cmd, isLast) =>
             {
                 if (isLast)
                 {
                     return;
                 }
                 //AndroidCommand command = cmd as AndroidCommand;
                 //if (command != null)
                 //{
                 //    command.Restart();
                 //}
             };
         }
         try
         {
             tp.Execute(OperationDelay, ContinueWhenError);
         }
         catch (Exception ex)
         {
             Log.Write("There is errpr, information is : {0}", ex.Message);
         }
     }
     Log.Write("aotumated testing completed.");
 }
예제 #29
0
        public void GeneralPerformanceTest(int count)
        {
            void buildSequence(ITestStepParent parent, int levels)
            {
                parent.ChildTestSteps.Add(new ManySettingsStep());
                parent.ChildTestSteps.Add(new DeferringResultStep());
                parent.ChildTestSteps.Add(new VirtualPropertiesStep());
                for (int i = 0; i < levels; i++)
                {
                    var seq = new SequenceStep();
                    parent.ChildTestSteps.Add(seq);
                    buildSequence(seq, levels / 2);
                }
            }

            var plan = new TestPlan {
                CacheXml = true
            };

            buildSequence(plan, 6);
            var total = Utils.FlattenHeirarchy(plan.ChildTestSteps, x => x.ChildTestSteps).Count();

            plan.Execute(); // warm up

            TimeSpan timeSpent = TimeSpan.Zero;

            for (int i = 0; i < count; i++)
            {
                using (TypeData.WithTypeDataCache())
                {
                    timeSpent += plan.Execute().Duration;
                }
            }


            var proc    = Process.GetCurrentProcess();
            var time    = proc.TotalProcessorTime;
            var time2   = DateTime.Now - proc.StartTime;
            var spentMs = timeSpent.TotalMilliseconds / count;

            Console.WriteLine("Time spent per plan: {0}ms", spentMs);
            Console.WriteLine("Time spent per step: {0}ms", spentMs / plan.Steps.Count);
        }
예제 #30
0
        public void NoNullResultGroups()
        {
            var plan = new TestPlan();

            plan.ChildTestSteps.Add(new CheckNullGroupStep());
            var run = plan.Execute();

            Assert.AreEqual(Verdict.Pass, run.Verdict);
            Assert.IsTrue(run.Parameters.All(x => x.Group != null));
        }