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);

            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))
#if true
                    result = 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();

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

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

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

            return(reporter.Summary.ErrorsAndFailures);
        }
Beispiel #2
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();

            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);
        }
        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;
        }