Exemplo n.º 1
0
        private CompareResult RunTest(ArgsProcessor argProc, CompareResult overallResult, ReportSet reportSet, TestDescription test)
        {
            _driver.SetWindowSize(test.WindowSize);

            _driver.OpenUrl(test.Url, test.DivSelector, test.TitleContains);

            var dirManager = new DirectoryManager(argProc);

            if (argProc.IsOptionOn(ArgsProcessor.Options.Run))
            {
                var reportThisTest = CompareActualPageVersusExpected(argProc, dirManager, test, _driver);
                var resultThisTest = reportThisTest.Result.Result;
                if (resultThisTest != CompareResult.Similar)
                {
                    overallResult = resultThisTest;
                }
                reportSet.Reports.Add(reportThisTest);
            }
            else if (argProc.IsOptionOn(ArgsProcessor.Options.Save))
            {
                SaveExpectedPage(dirManager, test, _driver);
            }
            else
            {
                throw new InvalidOperationException("Not a supported set of options");
            }
            return(overallResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// the main entry point for the process.
        /// </summary>
        public static int Main(string[] args)
        {
            var isVerbose = false;

            try
            {
                ArgsProcessor argProc = new ArgsProcessor(args);

                string message;
                if (!argProc.Validate(out message))
                {
                    Console.WriteLine(message);
                    Console.WriteLine(argProc.GetUsage());
                    return(1);
                }

                isVerbose = argProc.IsOptionOn(ArgsProcessor.Options.Verbose);

                if (argProc.IsOptionOn(ArgsProcessor.Options.TestSelf))
                {
                    RunSelfTest();
                }
                else if (argProc.IsOptionOn(ArgsProcessor.Options.AcceptChanges))
                {
                    ConvertActualToExpected(argProc);
                }
                else

                {
                    var result = RunTests(argProc);
                    return(GetResultAsReturnCode(result));
                }
            }
            catch (Exception ex)
            {
                Outputter.Output(ex, isVerbose);
                return(2);
            }
            return(0);
        }
Exemplo n.º 3
0
        private void CreateReports(ArgsProcessor argProc, ReportSet reports)
        {
            var reporters = ReportCreatorFactory.CreateReporters(argProc);

            foreach (var reporter in reporters)
            {
                if (reporter.HasSaveCapability())
                {
                    reporter.SaveReport(reports);
                }

                reporter.ShowReport(reports, argProc.IsOptionOn(ArgsProcessor.Options.QuietNotShowResults));
            }
        }
Exemplo n.º 4
0
        internal CompareResult RunTests(List <TestDescription> testsToRun, ArgsProcessor argProc)
        {
            ReportSet reportSet = CreateReport(argProc);

            try
            {
                var watch = Stopwatch.StartNew();

                using (_driver = new BrowserDriver())
                {
                    foreach (var test in testsToRun)
                    {
                        Outputter.Output("Running test: " + test.Name + " - " + test.Description);
                        reportSet.OverallResult = RunTest(argProc, reportSet.OverallResult, reportSet, test);
                        Outputter.OutputSeparator();
                    }

                    watch.Stop();
                    reportSet.Duration = watch.Elapsed;

                    if (argProc.IsOptionOn(ArgsProcessor.Options.Run))
                    {
                        CreateReports(argProc, reportSet);
                    }
                }
            }
            catch (Exception ex)
            {
                reportSet.Exception = ex.Message;

                throw;
            }
            finally
            {
                _driver = null;
                //try to log the exception in the combined report:
                AppendResultToCombinedReport(reportSet, argProc);
            }

            return(reportSet.OverallResult);
        }
Exemplo n.º 5
0
        private static CompareResult RunTests(ArgsProcessor argProc)
        {
            List <TestDescription> testsToRun = ReadTests(argProc);

            if (argProc.IsOptionOn(ArgsProcessor.Options.Save))
            {
                //protect the saved 'expected' files, by prompting the user:
                var message = "Get new saved 'expected' images? [Y to continue]";
                if (!IsUserOkToContinue(message))
                {
                    Outputter.Output("Cancelling...");
                    return(CompareResult.Cancelled);
                }
            }

            Outputter.OutputSeparator();
            var runner = new TestRunner();
            var result = runner.RunTests(testsToRun, argProc);

            Outputter.Output("Finished running tests:");
            Outputter.Output("[" + CompareResultHelper.GetResultAsString(result) + "]", CompareResultHelper.GetResultAsConsoleColor(result));
            return(result);
        }