Ejemplo n.º 1
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());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="step"></param>
        protected void RunTestStep(ITestStep step)
        {
            TestTraceListener        trace = new TestTraceListener();
            PlanRunCollectorListener pl    = new PlanRunCollectorListener();

            Log.AddListener(trace);

            TestPlan plan = new TestPlan();

            SetupPlan(plan, step);
            TestPlanRun run;

            using (Mutex mux = new Mutex(false, "TAPDatabaseAccessMutex"))
            {
                mux.WaitOne();

                run = plan.Execute(ResultSettings.Current.Concat(new IResultListener[] { pl }));
                mux.ReleaseMutex();
            }
            Log.RemoveListener(trace);
            CheckForInconclusive(trace.ErrorMessage);
            trace.AssertErrors(allowedLogErrors);
            Assert.AreEqual(Verdict.Pass, pl.StepRuns.First().Verdict, "Step ran to completion but verdict was 'fail'.\r\nLog:\r\n" + trace.allLog.ToString());
        }