Ejemplo n.º 1
0
        public int Execute(string[] args)
        {
            _options = new NUnitLiteOptions(_testAssembly == null, args);

            ExtendedTextWriter outWriter = null;

            if (_options.OutFile != null)
            {
                var outFile    = Path.Combine(_options.WorkDirectory, _options.OutFile);
                var textWriter = TextWriter.Synchronized(new StreamWriter(outFile));
                outWriter = new ExtendedTextWrapper(textWriter);
                Console.SetOut(outWriter);
            }
            else
            {
                outWriter = new ColorConsoleWriter(!_options.NoColor);
            }

            using (outWriter)
            {
                TextWriter errWriter = null;
                if (_options.ErrFile != null)
                {
                    var errFile = Path.Combine(_options.WorkDirectory, _options.ErrFile);
                    errWriter = TextWriter.Synchronized(new StreamWriter(errFile));
                    Console.SetError(errWriter);
                }

                using (errWriter)
                {
                    _textUI = new TextUI(outWriter, Console.In, _options);
                    return(Execute());
                }
            }
        }
Ejemplo n.º 2
0
        public int Execute(ExtendedTextWriter writer, TextReader reader, string[] args)
        {
            var options = new NUnitLiteOptions(args);
            var textUI  = new TextUI(writer, reader, options);

            return(Execute(textUI, options));
        }
Ejemplo n.º 3
0
        // Entry point called by AutoRun and by the portable nunitlite.runner
        public int Execute(ExtendedTextWriter writer, TextReader reader, NUnitLiteOptions options)
        {
            _textUI  = new TextUI(writer, reader, options);
            _options = options;

            return(Execute());
        }
Ejemplo n.º 4
0
        // Entry point called by AutoRun and by the .NET Standard nunitlite.runner
        public int Execute(ExtendedTextWriter writer, TextReader reader, string[] args)
        {
            _options = new NUnitLiteOptions(_testAssembly == null, args);

            _textUI = new TextUI(writer, reader, _options);

            return(Execute());
        }
Ejemplo n.º 5
0
        // The main program executes the tests. Output may be routed to
        // various locations, depending on the arguments passed.
        //
        // Arguments:
        //
        //  Arguments may be names of assemblies or options prefixed with '/'
        //  or '-'. Normally, no assemblies are passed and the calling
        //  assembly (the one containing this Main) is used. The following
        //  options are accepted:
        //
        //    -test:<testname>  Provides the name of a test to be exected.
        //                      May be repeated. If this option is not used,
        //                      all tests are run.
        //
        //    -out:PATH         Path to a file to which output is written.
        //                      If omitted, Console is used, which means the
        //                      output is lost on a platform with no Console.
        //
        //    -full             Print full report of all tests.
        //
        //    -result:PATH      Path to a file to which the XML test result is written.
        //
        //    -explore[:Path]   If specified, list tests rather than executing them. If a
        //                      path is given, an XML file representing the tests is written
        //                      to that location. If not, output is written to tests.xml.
        //
        //    -noheader,noh     Suppress display of the initial message.
        //
        //    -wait             Wait for a keypress before exiting.
        //
        //    -include:categorylist
        //             If specified, nunitlite will only run the tests with a category
        //             that is in the comma separated list of category names.
        //             Example usage: -include:category1,category2 this command can be used
        //             in combination with the -exclude option also note that exlude takes priority
        //             over all includes.
        //
        //    -exclude:categorylist
        //             If specified, nunitlite will not run any of the tests with a category
        //             that is in the comma separated list of category names.
        //             Example usage: -exclude:category1,category2 this command can be used
        //             in combination with the -include option also note that exclude takes priority
        //             over all includes
        public static int Main(string[] args)
        {
            var runner = new TextUI();

            runner.Execute(args);

            return(runner.Failure ? 1 : 0);
        }
Ejemplo n.º 6
0
        public int Execute(string[] args)
        {
            _options = new NUnitLiteOptions(_testAssembly == null, args);

            ExtendedTextWriter outWriter = null;

            if (_options.OutFile != null)
            {
                var outFile = Path.Combine(_options.WorkDirectory, _options.OutFile);
#if NETSTANDARD1_3 || NETSTANDARD1_6
                var textWriter = File.CreateText(outFile);
#else
                var textWriter = TextWriter.Synchronized(new StreamWriter(outFile));
#endif
                outWriter = new ExtendedTextWrapper(textWriter);
                Console.SetOut(outWriter);
            }
            else
            {
                outWriter = new ColorConsoleWriter();
            }

            TextWriter errWriter = null;
            if (_options.ErrFile != null)
            {
                var errFile = Path.Combine(_options.WorkDirectory, _options.ErrFile);
#if NETSTANDARD1_3 || NETSTANDARD1_6
                errWriter = File.CreateText(errFile);
#else
                errWriter = TextWriter.Synchronized(new StreamWriter(errFile));
#endif
                Console.SetError(errWriter);
            }

            try
            {
                _textUI = new TextUI(outWriter, Console.In, _options);
                return(Execute());
            }
            finally
            {
                if (_options.OutFile != null && outWriter != null)
#if NETSTANDARD1_3 || NETSTANDARD1_6
                { outWriter.Dispose(); }
#else
                { outWriter.Close(); }
#endif

                if (_options.ErrFile != null && errWriter != null)
#if NETSTANDARD1_3 || NETSTANDARD1_6
                { errWriter.Dispose(); }
#else
                { errWriter.Close(); }
#endif
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Execute the tests in the assembly, passing in
        /// a list of arguments.
        /// </summary>
        /// <param name="args">Execution options</param>
        public int Execute(Assembly callingAssembly, TextWriter writer, TextReader reader, string[] args)
        {
            var options = new NUnitLiteOptions(args);

            var _textUI = new TextUI(writer, reader, options);

            if (options.ShowVersion || !options.NoHeader)
            {
                _textUI.DisplayHeader();
            }

            if (options.ShowHelp)
            {
                _textUI.DisplayHelp();
                return(TextRunner.OK);
            }

            // We already showed version as a part of the header
            if (options.ShowVersion)
            {
                return(TextRunner.OK);
            }

            if (options.ErrorMessages.Count > 0)
            {
                _textUI.DisplayErrors(options.ErrorMessages);
                _textUI.DisplayHelp();

                return(TextRunner.INVALID_ARG);
            }

            if (options.InputFiles.Count > 0)
            {
                _textUI.DisplayError("Input assemblies may not be specified when using the NUnitLite AutoRunner");
                return(TextRunner.INVALID_ARG);
            }

            _textUI.DisplayTestFiles(new string[] { callingAssembly.GetName().Name });

            if (options.WaitBeforeExit && options.OutFile != null)
            {
                writer.WriteLine("Ignoring /wait option - only valid for Console");
            }

            try
            {
                return(new TextRunner(_textUI, options).Execute(callingAssembly));
            }
            finally
            {
                if (options.WaitBeforeExit)
                {
                    _textUI.WaitForUser("Press Enter key to continue . . .");
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Execute the tests in the assembly, passing in
        /// a list of arguments.
        /// </summary>
        /// <param name="args">Execution options</param>
        public int Execute(Assembly callingAssembly, TextWriter writer, TextReader reader, string[] args)
        {
            var options = new NUnitLiteOptions(args);

            var _textUI = new TextUI(writer, reader, options);

            if ( options.ShowVersion || !options.NoHeader)
                _textUI.DisplayHeader();

            if (options.ShowHelp)
            {
                _textUI.DisplayHelp();
                return TextRunner.OK;
            }

            // We already showed version as a part of the header
            if (options.ShowVersion)
                return TextRunner.OK;

            if (options.ErrorMessages.Count > 0)
            {
                _textUI.DisplayErrors(options.ErrorMessages);
                _textUI.DisplayHelp();

                return TextRunner.INVALID_ARG;
            }

            if (options.InputFiles.Count > 0)
            {
                _textUI.DisplayError("Input assemblies may not be specified when using the NUnitLite AutoRunner");
                return TextRunner.INVALID_ARG;
            }

            _textUI.DisplayTestFiles(new string[] { callingAssembly.GetName().Name });

            if (options.WaitBeforeExit && options.OutFile != null)
                writer.WriteLine("Ignoring /wait option - only valid for Console");

            try
            {
                return new TextRunner(_textUI, options).Execute(callingAssembly);
            }
            finally
            {
                if (options.WaitBeforeExit)
                    _textUI.WaitForUser("Press Enter key to continue . . .");
            }
        }
Ejemplo n.º 9
0
        /// <param name="options">The options to use when running the test</param>
        public TextRunner(TextUI textUI, NUnitLiteOptions options)
        {
            _textUI  = textUI;
            _options = options;

#if !PORTABLE
            if (!Directory.Exists(_options.WorkDirectory))
            {
                Directory.CreateDirectory(_options.WorkDirectory);
            }

#if !NETCF
            if (_options.TeamCity)
            {
                _teamCity = new TeamCityEventListener();
            }
#endif
#endif
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Execute the tests in the assembly, passing in
        /// a list of arguments.
        /// </summary>
        /// <param name="args">Execution options</param>
        public int Execute(string[] args)
        {
            var options = new NUnitLiteOptions(args);
            var callingAssembly = Assembly.GetCallingAssembly();

            var level = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), options.InternalTraceLevel ?? "Off", true);
#if NETCF  // NETCF: Try to unify
            InitializeInternalTrace(callingAssembly.GetName().CodeBase, level);
#else
            InitializeInternalTrace(callingAssembly.Location, level);
#endif

            ExtendedTextWriter outWriter = null;
            if (options.OutFile != null)
            {
                outWriter = new ExtendedTextWrapper(new StreamWriter(Path.Combine(options.WorkDirectory, options.OutFile)));
                Console.SetOut(outWriter);
            }

            TextWriter errWriter = null;
            if (options.ErrFile != null)
            {
                errWriter = new StreamWriter(Path.Combine(options.WorkDirectory, options.ErrFile));
                Console.SetError(errWriter);
            }

            var _textUI = new TextUI(outWriter, options);

            if (options.ShowVersion || !options.NoHeader)
                _textUI.DisplayHeader();

            if (options.ShowHelp)
            {
                _textUI.DisplayHelp();
                return TextRunner.OK;
            }

            // We already showed version as a part of the header
            if (options.ShowVersion)
                return TextRunner.OK;

            if (options.ErrorMessages.Count > 0)
            {
                _textUI.DisplayErrors(options.ErrorMessages);
                _textUI.DisplayHelp();

                return TextRunner.INVALID_ARG;
            }

#if !PORTABLE
            if (options.InputFiles.Count > 0)
            {
                _textUI.DisplayError("Input assemblies may not be specified when using the NUnitLite AutoRunner");
                return TextRunner.INVALID_ARG;
            }
#endif

            _textUI.DisplayRuntimeEnvironment();
            _textUI.DisplayTestFiles(new string[] { callingAssembly.GetName().Name });

            if (options.WaitBeforeExit && options.OutFile != null)
                _textUI.DisplayWarning("Ignoring /wait option - only valid for Console");

            try
            {
                return new TextRunner(_textUI, options).Execute(callingAssembly);
            }
            finally
            {
                if (options.WaitBeforeExit)
                    _textUI.WaitForUser("Press Enter key to continue . . .");

                if (outWriter != null)
                    outWriter.Close();

                if (errWriter != null)
                    errWriter.Close();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Execute a test run
        /// </summary>
        /// <param name="callingAssembly">The assembly from which tests are loaded</param>
        public int Execute(TextUI textUI, NUnitLiteOptions options)
        {
            _textUI = textUI;
            _options = options;
            _runner = new NUnitTestAssemblyRunner(new DefaultTestAssemblyBuilder());

            try
            {
#if !SILVERLIGHT && !PORTABLE
                if (!Directory.Exists(_options.WorkDirectory))
                    Directory.CreateDirectory(_options.WorkDirectory);

#if !NETCF
                if (_options.TeamCity)
                    _teamCity = new TeamCityEventListener();
#endif
#endif

                if (_options.ShowVersion || !_options.NoHeader)
                    _textUI.DisplayHeader();

                if (_options.ShowHelp)
                {
                    _textUI.DisplayHelp();
                    return TextRunner.OK;
                }

                // We already showed version as a part of the header
                if (_options.ShowVersion)
                    return TextRunner.OK;

                if (_options.ErrorMessages.Count > 0)
                {
                    _textUI.DisplayErrors(_options.ErrorMessages);
                    _textUI.DisplayHelp();

                    return TextRunner.INVALID_ARG;
                }

                _textUI.DisplayRuntimeEnvironment();

                var testFile = _testAssembly != null
                    ? AssemblyHelper.GetAssemblyPath(_testAssembly)
                    : _options.InputFiles.Count > 0
                        ? _options.InputFiles[0]
                        : null;

                if (testFile != null)
                {
                    _textUI.DisplayTestFiles(new string[] { testFile });
                    if (_testAssembly == null)
                        _testAssembly = AssemblyHelper.Load(testFile);
                }


                if (_options.WaitBeforeExit && _options.OutFile != null)
                    _textUI.DisplayWarning("Ignoring /wait option - only valid for Console");

                foreach (string nameOrPath in _options.InputFiles)
                    _assemblies.Add(AssemblyHelper.Load(nameOrPath));

                var runSettings = MakeRunSettings(_options);

                // We display the filters at this point so  that any exception message
                // thrown by CreateTestFilter will be understandable.
                _textUI.DisplayTestFilters();

                TestFilter filter = CreateTestFilter(_options);

                _runner.Load(_testAssembly, runSettings);
                return _options.Explore ? ExploreTests() : RunTests(filter, runSettings);
            }
            catch (FileNotFoundException ex)
            {
                _textUI.DisplayError(ex.Message);
                return FILE_NOT_FOUND;
            }
            catch (Exception ex)
            {
                _textUI.DisplayError(ex.ToString());
                return UNEXPECTED_ERROR;
            }
#if !SILVERLIGHT
            finally
            {
                if (_options.WaitBeforeExit)
                    _textUI.WaitForUser("Press Enter key to continue . . .");
            }
#endif
        }
Ejemplo n.º 12
0
 public int Execute(ExtendedTextWriter writer, TextReader reader, NUnitLiteOptions options)
 {
     var textUI = new TextUI(writer, reader, options);
     return Execute(textUI, options);
 }
Ejemplo n.º 13
0
 public int Execute(ExtendedTextWriter writer, TextReader reader, string[] args)
 {
     var options = new NUnitLiteOptions(args);
     var textUI = new TextUI(writer, reader, options);
     return Execute(textUI, options);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Execute a test run
        /// </summary>
        /// <param name="callingAssembly">The assembly from which tests are loaded</param>
        public int Execute(TextUI textUI, NUnitLiteOptions options)
        {
            _textUI  = textUI;
            _options = options;
            _runner  = new NUnitTestAssemblyRunner(new DefaultTestAssemblyBuilder());

            try
            {
#if !SILVERLIGHT && !PORTABLE
                if (!Directory.Exists(_options.WorkDirectory))
                {
                    Directory.CreateDirectory(_options.WorkDirectory);
                }

#if !NETCF
                if (_options.TeamCity)
                {
                    _teamCity = new TeamCityEventListener();
                }
#endif
#endif

                if (_options.ShowVersion || !_options.NoHeader)
                {
                    _textUI.DisplayHeader();
                }

                if (_options.ShowHelp)
                {
                    _textUI.DisplayHelp();
                    return(TextRunner.OK);
                }

                // We already showed version as a part of the header
                if (_options.ShowVersion)
                {
                    return(TextRunner.OK);
                }

                if (_options.ErrorMessages.Count > 0)
                {
                    _textUI.DisplayErrors(_options.ErrorMessages);
                    _textUI.DisplayHelp();

                    return(TextRunner.INVALID_ARG);
                }

                _textUI.DisplayRuntimeEnvironment();

                var testFile = _testAssembly != null
                    ? AssemblyHelper.GetAssemblyPath(_testAssembly)
                    : _options.InputFiles.Count > 0
                        ? _options.InputFiles[0]
                        : null;

                if (testFile != null)
                {
                    _textUI.DisplayTestFiles(new string[] { testFile });
                    if (_testAssembly == null)
                    {
                        _testAssembly = AssemblyHelper.Load(testFile);
                    }
                }


                if (_options.WaitBeforeExit && _options.OutFile != null)
                {
                    _textUI.DisplayWarning("Ignoring /wait option - only valid for Console");
                }

                foreach (string nameOrPath in _options.InputFiles)
                {
                    _assemblies.Add(AssemblyHelper.Load(nameOrPath));
                }

                var runSettings = MakeRunSettings(_options);

                // We display the filters at this point so  that any exception message
                // thrown by CreateTestFilter will be understandable.
                _textUI.DisplayTestFilters();

                TestFilter filter = CreateTestFilter(_options);

                _runner.Load(_testAssembly, runSettings);
                return(_options.Explore ? ExploreTests() : RunTests(filter, runSettings));
            }
            catch (FileNotFoundException ex)
            {
                _textUI.DisplayError(ex.Message);
                return(FILE_NOT_FOUND);
            }
            catch (Exception ex)
            {
                _textUI.DisplayError(ex.ToString());
                return(UNEXPECTED_ERROR);
            }
#if !SILVERLIGHT
            finally
            {
                if (_options.WaitBeforeExit)
                {
                    _textUI.WaitForUser("Press Enter key to continue . . .");
                }
            }
#endif
        }
Ejemplo n.º 15
0
        public int Execute(ExtendedTextWriter writer, TextReader reader, NUnitLiteOptions options)
        {
            var textUI = new TextUI(writer, reader, options);

            return(Execute(textUI, options));
        }
Ejemplo n.º 16
0
        //// <summary>
        //// Initializes a new instance of the <see cref="TextRunner"/> class.
        //// </summary>
        //// <param name="writer">The TextWriter to use.</param>
        //public TextRunner(ConsoleOptions options) : this(null, options) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TextRunner"/> class.
        /// </summary>
        /// <param name="textUI">The text-based user interface to output results of the run</param>
#if SILVERLIGHT
        public TextRunner(TextUI textUI)
        {
            _textUI = textUI;
            //_workDirectory = NUnit.Env.DefaultWorkDirectory;
        }
Ejemplo n.º 17
0
        public void LoadTest(string[] args)
        {
            //TLogger.Write("LoadTest ..................");
            _options = new NUnitLiteOptions(args);
            ExtendedTextWriter outWriter = null;

            outWriter = new ColorConsoleWriter();
            _textUI   = new TextUI(outWriter, Console.In, _options);
            _runner   = new NUnitTestAssemblyRunner(new DefaultTestAssemblyBuilder());
            try
            {
                #if !SILVERLIGHT && !PORTABLE
                if (!Directory.Exists(_options.WorkDirectory))
                {
                    Directory.CreateDirectory(_options.WorkDirectory);
                }

                #if !NETCF
                if (_options.TeamCity)
                {
                    _teamCity = new TeamCityEventListener();
                }
                #endif
                #endif

                if (_options.ShowVersion || !_options.NoHeader)
                {
                    _textUI.DisplayHeader();
                }

                if (_options.ShowHelp)
                {
                    _textUI.DisplayHelp();
                    return;
                }

                // We already showed version as a part of the header
                if (_options.ShowVersion)
                {
                    return;
                }

                if (_options.ErrorMessages.Count > 0)
                {
                    _textUI.DisplayErrors(_options.ErrorMessages);
                    _textUI.DisplayHelp();

                    return;
                }

                _textUI.DisplayRuntimeEnvironment();

                var testFile = _testAssembly != null
                                        ? AssemblyHelper.GetAssemblyPath(_testAssembly)
                                        : _options.InputFiles.Count > 0
                                        ? _options.InputFiles[0]
                                        : null;

                //TLogger.Write("Input File [0]:" + _options.InputFiles[0]);
                //TLogger.Write("Input File Format Size :"+ _options.InputFiles.Count);

                if (testFile != null)
                {
                    _textUI.DisplayTestFiles(new string[] { testFile });
                    //TLogger.Write("after DisplayTestFiles");
                    if (_testAssembly == null)
                    {
                        _testAssembly = AssemblyHelper.Load(testFile);
                    }
                }


                if (_options.WaitBeforeExit && _options.OutFile != null)
                {
                    _textUI.DisplayWarning("Ignoring /wait option - only valid for Console");
                }

                foreach (string nameOrPath in _options.InputFiles)
                {
                    //TLogger.Write("In foreach" + nameOrPath);
                    _assemblies.Add(AssemblyHelper.Load(nameOrPath));
                }

                // We display the filters at this point so  that any exception message
                // thrown by CreateTestFilter will be understandable.
                _textUI.DisplayTestFilters();
                var runSettings = MakeRunSettings(_options);

                TestFilter filter = CreateTestFilter(_options);

                _runner.Load(_testAssembly, runSettings);
            }
            catch (FileNotFoundException ex)
            {
                _textUI.DisplayError(ex.Message);
                return;
            }
            catch (Exception ex)
            {
                _textUI.DisplayError(ex.ToString());
                return;
            }
                #if !SILVERLIGHT
            finally
            {
                if (_options.WaitBeforeExit)
                {
                    _textUI.WaitForUser("Press Enter key to continue . . .");
                }
                if (_options.OutFile != null && outWriter != null)
                {
                    outWriter.Flush();
                }
            }
                #endif
        }
Ejemplo n.º 18
0
        //// <summary>
        //// Initializes a new instance of the <see cref="TextRunner"/> class.
        //// </summary>
        //// <param name="writer">The TextWriter to use.</param>
        //public TextRunner(ConsoleOptions options) : this(null, options) { }

        /// <summary>
        /// Initializes a new instance of the <see cref="TextRunner"/> class.
        /// </summary>
        /// <param name="textUI">The text-based user interface to output results of the run</param>
#if SILVERLIGHT
        public TextRunner(TextUI textUI)
        {
            _textUI = textUI;
            //_workDirectory = NUnit.Env.DefaultWorkDirectory;
        }
Ejemplo n.º 19
0
        /// <param name="options">The options to use when running the test</param>
        public TextRunner(TextUI textUI, NUnitLiteOptions options)
        {
            _textUI = textUI;
            _options = options;
            
#if !PORTABLE
            if (!Directory.Exists(_options.WorkDirectory))
                Directory.CreateDirectory(_options.WorkDirectory);

#if !NETCF
            if (_options.TeamCity)
                _teamCity = new TeamCityEventListener();
#endif
#endif
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Execute the tests in the assembly, passing in
        /// a list of arguments.
        /// </summary>
        /// <param name="args">Execution options</param>
        public int Execute(string[] args)
        {
            var options         = new NUnitLiteOptions(args);
            var callingAssembly = Assembly.GetCallingAssembly();

            var level = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), options.InternalTraceLevel ?? "Off", true);

#if NETCF  // NETCF: Try to unify
            InitializeInternalTrace(callingAssembly.GetName().CodeBase, level);
#else
            InitializeInternalTrace(callingAssembly.Location, level);
#endif

            ExtendedTextWriter outWriter = null;
            if (options.OutFile != null)
            {
                outWriter = new ExtendedTextWrapper(new StreamWriter(Path.Combine(options.WorkDirectory, options.OutFile)));
                Console.SetOut(outWriter);
            }

            TextWriter errWriter = null;
            if (options.ErrFile != null)
            {
                errWriter = new StreamWriter(Path.Combine(options.WorkDirectory, options.ErrFile));
                Console.SetError(errWriter);
            }

            var _textUI = new TextUI(outWriter, options);

            if (options.ShowVersion || !options.NoHeader)
            {
                _textUI.DisplayHeader();
            }

            if (options.ShowHelp)
            {
                _textUI.DisplayHelp();
                return(TextRunner.OK);
            }

            // We already showed version as a part of the header
            if (options.ShowVersion)
            {
                return(TextRunner.OK);
            }

            if (options.ErrorMessages.Count > 0)
            {
                _textUI.DisplayErrors(options.ErrorMessages);
                _textUI.DisplayHelp();

                return(TextRunner.INVALID_ARG);
            }

#if !PORTABLE
            if (options.InputFiles.Count > 0)
            {
                _textUI.DisplayError("Input assemblies may not be specified when using the NUnitLite AutoRunner");
                return(TextRunner.INVALID_ARG);
            }
#endif

            _textUI.DisplayRuntimeEnvironment();
            _textUI.DisplayTestFiles(new string[] { callingAssembly.GetName().Name });

            if (options.WaitBeforeExit && options.OutFile != null)
            {
                _textUI.DisplayWarning("Ignoring /wait option - only valid for Console");
            }

            try
            {
                return(new TextRunner(_textUI, options).Execute(callingAssembly));
            }
            finally
            {
                if (options.WaitBeforeExit)
                {
                    _textUI.WaitForUser("Press Enter key to continue . . .");
                }

                if (outWriter != null)
                {
                    outWriter.Close();
                }

                if (errWriter != null)
                {
                    errWriter.Close();
                }
            }
        }