Beispiel #1
0
        public void SimulateTestPlan()
        {
            var rl      = new LogResultListener();
            var planrun = new TestPlanRun();

            planrun.StartTime = DateTime.Now;
            planrun.Duration  = TimeSpan.FromSeconds(1);
            planrun.Parameters["TestPlanName"] = "test";

            // An issue was found where first setting planrun.Parameters["Verdict"] to a string and
            // then getting it as a Verdict.
            planrun.Parameters["Verdict"] = "Pass";
            Assert.AreEqual(Verdict.Pass, planrun.Verdict);
            rl.OnTestPlanRunStart(planrun);

            string testString = "Test Test Test";

            var ms = new MemoryStream(Encoding.UTF8.GetBytes(testString));

            rl.OnTestPlanRunCompleted(planrun, ms);
            var file = rl.FilePath.Expand(planrun);

            try
            {
                Assert.AreEqual(testString, File.ReadAllText(file));
            }
            finally
            {
                File.Delete(file);
            }
        }
Beispiel #2
0
 public override void OnTestPlanRunStart(TestPlanRun planRun)
 {
     GuiHelper.GuiInvoke(() =>
     {
         btn.IsEnabled = false;
         txt.Text      = "";
     });
 }
Beispiel #3
0
 public void TestPlanRunThrowsError()
 {
     var client = new TargetProcessClient
     {
         ApiSiteInfo = new ApiSiteInfo(TargetProcessRoutes.Route.TestPlanRuns)
     };
     var testPlanRun = new TestPlanRun
     {
     };
 }
Beispiel #4
0
        // This example loads and runs a predefined test plan using the TAP API, the same interface the TAP GUI uses.
        // Use this to create custom GUIs or Operator interfaces. If no GUI is needed, the CLI may be a better alternative.
        // To run this example you must specify a path to a .TapPlan file.

        private static void Main(string[] args)
        {
            Console.WriteLine("\nThis example shows using the TAP API to control loading and running a TestPlan.");

            try
            {
                // If you have plugins in directories different from the location of your TAP_PATH, then add those directories here.
                // PluginManager.DirectoriesToSearch.Add(@"C:\SomeOtherDirectory");

                // Start finding plugins.
                PluginManager.SearchAsync();

                // Point to log file to be used.
                SessionLogs.Initialize("console_log.txt");

                // Determine path to .TapPlan file.
                string absoluteTestPlanPath;
                if (args.Length == 1 && File.Exists(args[0]))
                {
                    absoluteTestPlanPath = args[0];
                }
                else
                {
                    Console.WriteLine("Please specify an absolute path to a .TapPlan file.");
                    return;
                }

                // ResultsListeners are configured by settings files, using the TAP GUI.
                // If settings files do not exist, then a default set of settings files,
                // including a default "Text Log" listener will be used.
                // Alternately, RestultListeners can be configured via TAP API. See the BuildTestPlan.Api example.

                // Load the Test Plan.
                TestPlan myTestPlan = TestPlan.Load(absoluteTestPlanPath);

                // Execute the Test Plan.
                TestPlanRun myTestPlanRun = myTestPlan.Execute();
                Console.WriteLine("Loaded and ran \n{0}", absoluteTestPlanPath);

                // Test Plan properties are accessible.
                Console.WriteLine("TestPlan verdict={0}", myTestPlanRun.Verdict);

                // After the Test Plan has been run Macros, if used, can be expanded.
                SessionLogs.Rename(EngineSettings.Current.SessionLogPath.Expand(date: DateTime.Now));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
            }
            finally
            {
                Console.WriteLine("Press any key to continue.");
                Console.ReadLine();
            }
        }
Beispiel #5
0
 public override void OnTestPlanRunCompleted(TestPlanRun planRun, Stream logStream)
 {
     base.OnTestPlanRunCompleted(planRun, logStream);
     //Assert.AreEqual(5, planRun.Children.Count());
     //CollectionAssert.AllItemsAreUnique(planRun.Children);
     //foreach (TestStepRun stepRun in planRun.Children)
     //{
     //Assert.IsNotNull(stepRun.Children);
     //Assert.AreEqual(0, stepRun.Children.Count());
     //    Thread.Sleep(100);
     //}
 }
 public override void OnTestPlanRunStart(TestPlanRun planRun)
 {
     EnterLocked(ref OnTestPlanRunStartLock, "OnTestPlanRunStart");
     try
     {
         NeedsOpen("OnTestPlanRunStart");
         IsTestPlanRunning = true;
         base.OnTestPlanRunStart(planRun);
     }
     finally
     {
         OnTestPlanRunStartLock.Exit(false);
     }
 }
Beispiel #7
0
 public override void OnTestPlanRunStart(TestPlanRun planRun)
 {
     this.planrun = planRun;
     if (CrashResultPhase == ResultPhase.PlanRunStart)
     {
         if (AbortPlan)
         {
             TapThread.Current.Abort();
         }
         else
         {
             throw new Exception("Intended");
         }
     }
 }
Beispiel #8
0
 public override void OnTestPlanRunCompleted(TestPlanRun planRun, System.IO.Stream logStream)
 {
     FinalVerdict = planrun.Verdict;
     if (CrashResultPhase == ResultPhase.PlanRunCompleted)
     {
         if (AbortPlan)
         {
             TapThread.Current.Abort();
         }
         else
         {
             throw new Exception("Intended");
         }
     }
     planrun = null;
 }
Beispiel #9
0
        public void TestPlanRunWithNullArgument()
        {
            // As ExpectedException has been removed from nunit 3, I will have a try-catch block to catch the ArgumentNullException
            bool argumentNullExceptionCaught = false;

            try
            {
                TestPlanRun testPlanRun = new TestPlanRun(null, null, DateTime.Now, 0);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual($"Value cannot be null.{Environment.NewLine}Parameter name: plan", ex.Message);
                argumentNullExceptionCaught = true;
            }

            Assert.IsTrue(argumentNullExceptionCaught, "ArgumentNullException was not thrown");
        }
Beispiel #10
0
 public override void OnTestPlanRunCompleted(TestPlanRun planRun, Stream logStream)
 {
     GuiHelper.GuiInvoke(() =>
     {
         btn.IsEnabled  = true;
         txt.Text       = planRun.Verdict.ToString();
         txt.Foreground = Brushes.Gray;
         if (planRun.Verdict == Verdict.Pass)
         {
             txt.Foreground = Brushes.Green;
         }
         if (planRun.Verdict == Verdict.Fail)
         {
             txt.Foreground = Brushes.Red;
         }
     });
 }
Beispiel #11
0
        public override void OnTestPlanRunCompleted(TestPlanRun planRun, Stream logStream)
        {
            base.OnTestPlanRunCompleted(planRun, logStream);

            try
            {
                using (StdfFileWriter fw = new StdfFileWriter(MacroPathAttribute.Expand(FilePath, planRun)))
                {
                    fw.WriteRecords(Records);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw ex;
            }
        }
 public override void OnTestPlanRunCompleted(TestPlanRun planRun, System.IO.Stream logStream)
 {
     EnterLocked(ref OnTestPlanRunCompletedLock, "OnTestPlanRunCompleted");
     try
     {
         NeedsOpen("OnTestPlanRunCompleted");
         if (!IsTestPlanRunning)
         {
             throw new Exception("TestPlan is not running");
         }
         IsTestPlanRunning = false;
         base.OnTestPlanRunCompleted(planRun, logStream);
     }
     finally
     {
         OnTestPlanRunCompletedLock.Exit(false);
     }
 }
        public void RunCompositeMetaData()
        {
            PlanRunCollectorListener listener = new PlanRunCollectorListener();

            ResultSettings.Current.Add(listener);

            TestTraceListener trace = new TestTraceListener();

            Log.AddListener(trace);

            TestPlan    target = getTestTestPlan();
            TestPlanRun run    = target.Execute();

            Log.RemoveListener(trace);

            ResultSettings.Current.Remove(listener);

            Assert.IsTrue(run.Parameters.Any(par => par.Value.ToString() == "Test Instrument"));
            Assert.IsFalse(run.Parameters.Any(par => par.Name == "Comment"));
        }
Beispiel #14
0
        void RunTestPlanCommon()
        {
            // Add database result output:
            PlanRunCollectorListener pl = new PlanRunCollectorListener();

            const string outputDir = @"PlatformTests/";

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            // Set log file path:
            LogResultListener log = ResultSettings.Current.GetDefault <LogResultListener>();

            if (log == null)
            {
                log = new LogResultListener();
                ResultSettings.Current.Add(log);
            }
            string logFilePath = $"{outputDir}/{plan.Name}.log";

            log.FilePath.Text = logFilePath;
            TestPlanRun planRun = plan.Execute(ResultSettings.Current.Concat(new IResultListener[] { pl }));

            List <string> allowedMessages = new List <string>
            {
                "DUT chipset is not verified to work with this application."
            };

            ResultSettings.Current.Remove(log);
            Log.RemoveListener(trace);
            trace.AssertErrors(allowedMessages);
            foreach (var stepRun in pl.StepRuns)
            {
                Assert.IsTrue(stepRun.Verdict <= Verdict.Pass, "TestPlan ran to completion but verdict was '{1}' on step '{0}'.\r\nLog:\r\n{2}",
                              stepRun.TestStepName,
                              stepRun.Verdict, trace.GetLog());
            }
        }
 public override void OnTestPlanRunCompleted(TestPlanRun planRun, System.IO.Stream logStream)
 {
     PlanRuns.Add(planRun);
     LogString = new System.IO.StreamReader(logStream).ReadToEnd();
 }
 public override void OnTestPlanRunStart(TestPlanRun planRun)
 {
     base.OnTestPlanRunStart(planRun);
     Results.Clear();
 }
Beispiel #17
0
        public void SweepRaceBug()
        {
            // test that validation rules can be checked while the test plan is running
            // without causing an error. The validation rules does not need to do actual validation
            // but since SweepLoop and SweepLoopRange modifies its child steps this could cause an error
            // as shown by SweepRaceBugCheckStep and SweepRaceBugStep.
            var plan   = new TestPlan();
            var repeat = new RepeatStep {
                Count = 10, Action = RepeatStep.RepeatStepAction.Fixed_Count
            };
            var loop = new SweepLoop();

            repeat.ChildTestSteps.Add(loop);
            loop.ChildTestSteps.Add(new SweepRaceBugStep()
            {
            });
            loop.ChildTestSteps.Add(new SweepRaceBugCheckStep()
            {
            });
            var steptype = TypeData.FromType(typeof(SweepRaceBugStep));
            var member   = steptype.GetMember(nameof(SweepRaceBugStep.Frequency));
            var member2  = TypeData.FromType(typeof(SweepRaceBugCheckStep)).GetMember(nameof(SweepRaceBugCheckStep.Frequency2));

            var lst = new List <SweepParam>();

            double[] values = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            lst.Add(new SweepParam(new[] { member }, values.Cast <object>().ToArray()));
            lst.Add(new SweepParam(new[] { member2 }, values.Cast <object>().ToArray()));
            loop.SweepParameters = lst;

            var loopRange = new SweepLoopRange();

            loopRange.SweepStart  = 1;
            loopRange.SweepEnd    = 10;
            loopRange.SweepPoints = 10;
            loopRange.ChildTestSteps.Add(new SweepRaceBugStep()
            {
            });
            loopRange.ChildTestSteps.Add(new SweepRaceBugCheckStep()
            {
            });
            loopRange.SweepProperties = new List <IMemberData> {
                member, member2
            };
            var repeat2 = new RepeatStep {
                Count = 10, Action = RepeatStep.RepeatStepAction.Fixed_Count
            };

            repeat2.ChildTestSteps.Add(loopRange);
            var parallel = new ParallelStep();

            plan.ChildTestSteps.Add(parallel);
            parallel.ChildTestSteps.Add(repeat);
            parallel.ChildTestSteps.Add(repeat2);

            TestPlanRun run = null;

            TapThread.Start(() => run = plan.Execute());
            TapThread.Start(() =>
            {
                while (run == null)
                {
                    loopRange.Error.ToList();
                }
            });
            while (run == null)
            {
                loop.Error.ToList();
            }

            Assert.AreEqual(Verdict.NotSet, run.Verdict);
        }
Beispiel #18
0
        public void CreateTestPlanRunThrowsError()
        {
            var client = CommonMethods.GetClientByRoute(TargetProcessRoutes.Route.TestPlanRuns);

            var testPlanRun = new TestPlanRun();
        }
Beispiel #19
0
        public override void OnTestPlanRunStart(TestPlanRun planRun)
        {
            TestPlanRunStartedEventArgs e = new TestPlanRunStartedEventArgs(planRun);

            RaiseTestPlanRunStarted(e);
        }
 public override void OnTestPlanRunStart(TestPlanRun planRun)
 {
     Log.Info("Test plan \"{0}\" started", planRun.TestPlanName);
 }
Beispiel #21
0
 public IApiResponse <TestPlanRun> CreateTestPlanRun(TestPlanRun testPlanRun) => CreateData <TestPlanRun>(testPlanRun);
Beispiel #22
0
 public void OnTestPlanRunCompleted(TestPlanRun planRun, Stream logStream)
 {
 }
Beispiel #23
0
        public override void OnTestPlanRunCompleted(TestPlanRun planRun, Stream logStream)
        {
            TestPlanRunCompletedEventArgs e = new TestPlanRunCompletedEventArgs(planRun, logStream);

            RaiseTestPlanRunCompleted(e);
        }
Beispiel #24
0
 public TestPlanRunStartedEventArgs(TestPlanRun testplanRun)
 {
     TestPlanRun = testplanRun;
 }
Beispiel #25
0
 public override void OnTestPlanRunStart(TestPlanRun planRun)
 {
     base.OnTestPlanRunStart(planRun);
     Records = new List <StdfRecord>();
 }
Beispiel #26
0
 public Task <IApiResponse <TestPlanRun> > CreateTestPlanRunAsync(TestPlanRun testPlanRun) => CreateDataAsync <TestPlanRun>(testPlanRun);
Beispiel #27
0
 public TestPlanRunCompletedEventArgs(TestPlanRun testPlanRun, Stream logStream)
 {
     TestPlanRun = testPlanRun;
     LogStream   = logStream;
 }
Beispiel #28
0
 public void OnTestPlanRunStart(TestPlanRun planRun)
 {
 }
 public override void OnTestPlanRunCompleted(TestPlanRun planRun, Stream logStream)
 {
     Log.Info("Test plan completed, run duration = {0} seconds, with {1} params", planRun.Duration.TotalSeconds,
              planRun.Parameters.Count);
 }