private int ExploreTests(TestPackage package, TestFilter filter)
        {
            XmlNode result = engine.Explore(package, filter);

            if (options.ExploreOutputSpecifications.Count == 0)
            {
                new TestCaseOutputWriter().WriteResultFile(result, Console.Out);
            }
            else
            {
                var outputManager = new OutputManager(result, this.workDirectory);

                foreach (OutputSpecification spec in options.ExploreOutputSpecifications)
                {
                    outputManager.WriteTestFile(spec);
                }
            }

            return(ConsoleRunner.OK);
        }
Example #2
0
        private int ExploreTests(TestPackage package, TestFilter filter)
        {
            XmlNode result = null;

            using (var runner = _engine.GetRunner(package))
                result = runner.Explore(filter);

            if (_options.ExploreOutputSpecifications.Count == 0)
            {
                new TestCaseOutputWriter().WriteResultFile(result, Console.Out);
            }
            else
            {
                var outputManager = new OutputManager(result, _workDirectory);

                foreach (OutputSpecification spec in _options.ExploreOutputSpecifications)
                {
                    outputManager.WriteTestFile(spec);
                }
            }

            return(ConsoleRunner.OK);
        }
Example #3
0
        private int RunTests(TestPackage package, TestFilter filter)
        {
            // TODO: We really need options as resolved by engine for most of  these
            DisplayRequestedOptions();

            // TODO: Incorporate this in EventCollector?
            RedirectOutputAsRequested();

            TestEventHandler eventHandler = new TestEventHandler(options, outWriter, errorWriter);

            ITestEngineResult engineResult = null;

            // Save things that might be messed up by a bad test
            TextWriter savedOut   = Console.Out;
            TextWriter savedError = Console.Error;

            DateTime startTime = DateTime.Now;

            try
            {
                using (new ColorConsole(ColorStyle.Output))
#if true
                    engineResult = engine.Run(package, eventHandler, filter);
#else
                    using (ITestRunner runner = engine.GetRunner(package))
                    {
                        if (runner.Load(package))
                        {
                            engineResult = runner.Run(eventHandler, testFilter);
                        }
                    }
#endif
            }
            finally
            {
                Console.SetOut(savedOut);
                Console.SetError(savedError);

                RestoreOutput();
            }

            //Console.WriteLine();

            int returnCode = UNEXPECTED_ERROR;

            if (engineResult.HasErrors)
            {
                DisplayErrorMessages(engineResult);
            }
            else
            {
                ResultReporter reporter = new ResultReporter(engineResult.Xml, options);
                reporter.ReportResults();

                // TODO: Inject this?
                var outputManager = new OutputManager(engineResult.Xml, this.workDirectory);

                foreach (var outputSpec in options.ResultOutputSpecifications)
                {
                    outputManager.WriteResultFile(outputSpec, startTime);
                }

                returnCode = reporter.Summary.ErrorsAndFailures;

                //if ( collector.HasExceptions )
                //{
                //    collector.WriteExceptions();
                //    returnCode = UNEXPECTED_ERROR;
                //}
            }

            return(returnCode);
        }
        private int ExploreTests(TestPackage package, TestFilter filter)
        {
            XmlNode result = null;

            using (var runner = _engine.GetRunner(package))
                result = runner.Explore(filter);

            if (_options.ExploreOutputSpecifications.Count == 0)
            {
                new TestCaseOutputWriter().WriteResultFile(result, Console.Out);
            }
            else
            {
                var outputManager = new OutputManager(result, _workDirectory);

                foreach (OutputSpecification spec in _options.ExploreOutputSpecifications)
                    outputManager.WriteTestFile(spec);
            }

            return ConsoleRunner.OK;
        }
        private int RunTests(TestPackage package, TestFilter filter)
        {
            // TODO: We really need options as resolved by engine for most of  these
            DisplayRequestedOptions();

            // TODO: Incorporate this in EventCollector?
            RedirectOutputAsRequested();

            var labels = _options.DisplayTestLabels != null
                ? _options.DisplayTestLabels.ToUpperInvariant()
                : "ON";
            TestEventHandler eventHandler = new TestEventHandler(_outWriter, labels);

            XmlNode result = null;

            // Save things that might be messed up by a bad test
            TextWriter savedOut = Console.Out;
            TextWriter savedError = Console.Error;

            DateTime startTime = DateTime.Now;

            try
            {
                using ( new ColorConsole( ColorStyle.Output ) )
                using (ITestRunner runner = _engine.GetRunner(package))
                {
                    result = runner.Run(eventHandler, filter);
                }
            }
            finally
            {
                Console.SetOut(savedOut);
                Console.SetError(savedError);

                RestoreOutput();
            }

            //Console.WriteLine();

            ResultReporter reporter = new ResultReporter(result, _options);
            reporter.ReportResults();

            // TODO: Inject this?
            var outputManager = new OutputManager(result, _workDirectory);

            foreach (var outputSpec in _options.ResultOutputSpecifications)
                outputManager.WriteResultFile(outputSpec, startTime);

            return reporter.Summary.ErrorsAndFailures;
        }