static void Main(string[] args) { const string resultsPath = "\\PureMVC.DotNETCF.Tests.Results.txt"; using (TextWriter writer = new StreamWriter(new FileStream(resultsPath, FileMode.Create))) { TextUI testRunner = new TextUI(writer); testRunner.Execute(new string[] { "PureMVC.DotNETCF.Tests, Version=3.0.0.0" }); } }
public void RunWithTextUI(Assembly assembly, string reportFileName, string category, TextUIOptionBuilder.XmlReportFormat format = TextUIOptionBuilder.XmlReportFormat.NUnit2) { using (var sw = new StringWriter()) { TextUI runner = new TextUI(sw); TextUIOptionBuilder builder = new TextUIOptionBuilder(); builder.AddAssembleFileName(assembly.FullName) .SetReportFileName(reportFileName) .SetReportFormat(format) .SetIncludeCategory (category); string[] option = builder.Build(); runner.Execute(option); Debug.Log(sw.GetStringBuilder().ToString()); } }
/// <param name="options">The options to use when running the test</param> public TextRunner(TextUI textUI, NUnitLiteOptions options) { _textUI = textUI; _options = options; if (!Directory.Exists(_options.WorkDirectory)) { Directory.CreateDirectory(_options.WorkDirectory); } #if !NETCF if (_options.TeamCity) { _teamCity = new TeamCityEventListener(); } #endif }
public void RunWithTextUI(Assembly assembly, string reportFileName, TextUIOptionBuilder.XmlReportFormat format = TextUIOptionBuilder.XmlReportFormat.NUnit2) { if (assembly == null) { throw new ArgumentNullException("assembly was null."); } using (var sw = new StringWriter()) { TextUI runner = new TextUI(sw); TextUIOptionBuilder builder = new TextUIOptionBuilder(); builder.AddAssembleFileName(assembly.FullName) .SetReportFileName(reportFileName) .SetReportFormat(format); string[] option = builder.Build(); runner.Execute(option); Debug.Log(sw.GetStringBuilder().ToString()); } }
//// <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; }
//// <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; }
/// <param name="options">The options to use when running the test</param> public TextRunner(TextUI textUI, NUnitLiteOptions options) { _textUI = textUI; _options = options; if (!Directory.Exists(_options.WorkDirectory)) Directory.CreateDirectory(_options.WorkDirectory); #if !NETCF if (_options.TeamCity) _teamCity = new TeamCityEventListener(); #endif }
/// <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 ConsoleOptions(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.NoHeader) { _textUI.DisplayHeader(); } if (options.ShowHelp) { _textUI.DisplayHelp(); 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 }); _textUI.DisplayRuntimeEnvironment(); _textUI.DisplayRequestedOptions(); 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(); } } }
public static void Execute(TextUI textUI, string[] args) { textUI.Execute(args); }
/// <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 ConsoleOptions(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.NoHeader) _textUI.DisplayHeader(); if (options.ShowHelp) { _textUI.DisplayHelp(); 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.DisplayTestFiles(new string[] { callingAssembly.GetName().Name }); _textUI.DisplayRuntimeEnvironment(); _textUI.DisplayRequestedOptions(); 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(); } }