public int Execute(string[] args) { var options = new NUnitLiteOptions(args); ExtendedTextWriter outWriter = null; outWriter = new ColorConsoleWriter(); try { return(Execute(outWriter, Console.In, options)); } finally { if (options.OutFile != null && outWriter != null) { outWriter.Flush(); } } }
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 }