static ExecutionResult Execute(CommandLineParser commandLineParser) { var options = commandLineParser.Options; var summary = new ExecutionResult(); var stopwatch = new Stopwatch(); stopwatch.Start(); foreach (var assemblyPath in commandLineParser.AssemblyPaths) { var result = Execute(assemblyPath, options); summary.Add(result); } stopwatch.Stop(); if (summary.AssemblyResults.Count > 1) Summarize(summary, stopwatch.Elapsed); SaveReport(options, summary); return summary; }
static int Main(string[] args) { try { var commandLineParser = new CommandLineParser(args); if (commandLineParser.HasErrors) { using (Foreground.Red) foreach (var error in commandLineParser.Errors) Console.WriteLine(error); Console.WriteLine(); Console.WriteLine(CommandLineParser.Usage()); return FatalError; } var summary = Execute(commandLineParser); return summary.Failed; } catch (Exception exception) { using (Foreground.Red) Console.WriteLine($"Fatal Error: {exception}"); return FatalError; } }
public void ParsesExistingAssemblyPaths() { var parser = new CommandLineParser(assemblyPathA, assemblyPathB); parser.AssemblyPaths.ShouldEqual(assemblyPathA, assemblyPathB); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void DemandsAtLeastOneAssemblyPath() { var parser = new CommandLineParser(); parser.AssemblyPaths.ShouldBeEmpty(); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeTrue(); parser.Errors.ShouldEqual("Missing required test assembly path(s)."); }
public void DemandsThatCustomParameterKeysCannotBeEmpty() { var parser = new CommandLineParser("assembly.dll", "--parameter", "=value"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeTrue(); parser.Errors.ShouldEqual("Custom parameter =value is missing its required key."); }
public void DemandsThatAllOptionsBeRecognized() { var parser = new CommandLineParser("assembly.dll", "--typo", "value"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeTrue(); parser.Errors.ShouldEqual("Option --typo is not recognized."); }
public void DemandsThatOptionValuesCannotLookLikeKeys() { var parser = new CommandLineParser("--NUnitXml", "--anotherKey"); parser.AssemblyPaths.ShouldBeEmpty(); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeTrue(); parser.Errors.ShouldEqual("Option --NUnitXml is missing its required value."); }
public void ParsesAssemblyPaths() { var parser = new CommandLineParser("foo.dll", "bar.dll"); parser.AssemblyPaths.ShouldEqual("foo.dll", "bar.dll"); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void DemandsAssemblyPathsExist() { var parser = new CommandLineParser("foo.dll", "bar.dll"); parser.AssemblyPaths.ShouldEqual("foo.dll", "bar.dll"); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeTrue(); parser.Errors.ShouldEqual("Specified test assembly does not exist: foo.dll", "Specified test assembly does not exist: bar.dll"); }
static int Main(string[] args) { try { var commandLineParser = new CommandLineParser(args); if (commandLineParser.HasErrors) { using (Foreground.Red) foreach (var error in commandLineParser.Errors) Console.WriteLine(error); Console.WriteLine(); Console.WriteLine(CommandLineParser.Usage()); return FatalError; } foreach (var assemblyPath in commandLineParser.AssemblyPaths) { if (!File.Exists(assemblyPath)) { using (Foreground.Red) Console.WriteLine("Specified test assembly does not exist: " + assemblyPath); Console.WriteLine(); Console.WriteLine(CommandLineParser.Usage()); return FatalError; } } var executionResult = new ExecutionResult(); var stopwatch = new Stopwatch(); stopwatch.Start(); foreach (var assemblyPath in commandLineParser.AssemblyPaths) { var result = Execute(assemblyPath, commandLineParser.Options); executionResult.Add(result); } stopwatch.Stop(); if (executionResult.AssemblyResults.Count > 1) Summarize(executionResult, stopwatch.Elapsed); ProduceReports(commandLineParser.Options, executionResult); return executionResult.Failed; } catch (Exception exception) { using (Foreground.Red) Console.WriteLine("Fatal Error: {0}", exception); return FatalError; } }
public void CustomParametersBehaveLikeSwitchesWhenNoEqualSignIsSpecified() { var parser = new CommandLineParser("assembly.dll", "--parameter", "switch"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Keys.ShouldEqual("switch"); parser.Options["switch"].ShouldEqual("on"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void ParsesTeamCityOutputFlag() { var parser = new CommandLineParser(assemblyPathA, "--TeamCity", "off"); parser.AssemblyPaths.ShouldEqual(assemblyPathA); parser.Options.Keys.ShouldEqual("TeamCity"); parser.Options["TeamCity"].ShouldEqual("off"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void DemandsAssemblyDirectoryContainsFixie() { var mscorlib = typeof(string).Assembly.Location; var parser = new CommandLineParser(mscorlib); parser.AssemblyPaths.ShouldEqual(mscorlib); parser.Options.Count.ShouldEqual(0); parser.HasErrors.ShouldBeTrue(); parser.Errors.ShouldEqual($"Specified assembly {mscorlib} does not appear to be a test assembly. Ensure that it references Fixie.dll and try again."); }
public void DemandsThatOptionsHaveExplicitValues() { var parser = new CommandLineParser("--NUnitXml", "TestResult.xml", "--key"); parser.AssemblyPaths.ShouldBeEmpty(); parser.Options.Keys.ShouldEqual("NUnitXml"); parser.Options["NUnitXml"].ShouldEqual("TestResult.xml"); parser.HasErrors.ShouldBeTrue(); parser.Errors.ShouldEqual("Option --key is missing its required value."); }
public void ParsesNUnitXmlOutputFile() { var parser = new CommandLineParser("assembly.dll", "--NUnitXml", "TestResult.xml"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Keys.ShouldEqual("NUnitXml"); parser.Options["NUnitXml"].ShouldEqual("TestResult.xml"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void ParsesOptions() { var parser = new CommandLineParser(assemblyPathA, "--key", "value", "--otherKey", "otherValue"); parser.AssemblyPaths.ShouldEqual(assemblyPathA); parser.Options.Keys.ShouldEqual("key", "otherKey"); parser.Options["key"].ShouldEqual("value"); parser.Options["otherKey"].ShouldEqual("otherValue"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void ParsesAllOptionsValuesProvidedForEachOptionKey() { var parser = new CommandLineParser("assembly.dll", "--a", "1", "--b", "2", "--a", "3"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Keys.OrderBy(x => x).ShouldEqual("a", "b"); parser.Options["a"].ShouldEqual("1", "3"); parser.Options["b"].ShouldEqual("2"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void ParsesAllCustomParameterValuesProvidedForEachCustomKeyKey() { var parser = new CommandLineParser("assembly.dll", "--parameter", "a=1", "--parameter", "b=2", "--parameter", "a=3"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Keys.OrderBy(x => x).ShouldEqual("a", "b"); parser.Options["a"].ShouldEqual("1", "3"); parser.Options["b"].ShouldEqual("2"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void ParsesAssemblyPathsMixedWithOptionsOptions() { var parser = new CommandLineParser("a.dll", "--include", "CategoryA", "b.dll", "--NUnitXml", "TestResult.xml", "--oops", "c.dll", "d.dll", "--include", "CategoryB", "--mode", "integration", "e.dll"); parser.AssemblyPaths.ShouldEqual("a.dll", "b.dll", "d.dll", "e.dll"); parser.Options.Keys.OrderBy(x => x).ShouldEqual("include", "mode", "NUnitXml", "oops"); parser.Options["include"].ShouldEqual("CategoryA", "CategoryB"); parser.Options["mode"].ShouldEqual("integration"); parser.Options["NUnitXml"].ShouldEqual("TestResult.xml"); parser.Options["oops"].ShouldEqual("c.dll"); parser.Options["nonexistent"].ShouldBeEmpty(); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
static ExecutionResult Execute(CommandLineParser commandLineParser) { var options = commandLineParser.Options; var summary = new ExecutionResult(); foreach (var assemblyPath in commandLineParser.AssemblyPaths) { var result = Execute(assemblyPath, options); summary.Add(result); } SaveReport(options, summary); return summary; }
static int Main(string[] args) { try { var commandLineParser = new CommandLineParser(args); if (commandLineParser.HasErrors) { using (Foreground.Red) foreach (var error in commandLineParser.Errors) { Console.WriteLine(error); } Console.WriteLine(); Console.WriteLine(CommandLineParser.Usage()); return(FatalError); } foreach (var assemblyPath in commandLineParser.AssemblyPaths) { if (!File.Exists(assemblyPath)) { using (Foreground.Red) Console.WriteLine("Specified test assembly does not exist: " + assemblyPath); Console.WriteLine(); Console.WriteLine(CommandLineParser.Usage()); return(FatalError); } } var executionResult = new ExecutionResult(); var stopwatch = new Stopwatch(); stopwatch.Start(); foreach (var assemblyPath in commandLineParser.AssemblyPaths) { var result = Execute(assemblyPath, commandLineParser.Options); executionResult.Add(result); } stopwatch.Stop(); if (executionResult.AssemblyResults.Count > 1) { Summarize(executionResult, stopwatch.Elapsed); } ProduceReports(commandLineParser.Options, executionResult); return(executionResult.Failed); } catch (Exception exception) { using (Foreground.Red) Console.WriteLine("Fatal Error: {0}", exception); return(FatalError); } }
public void ParsesCustomParameters() { var parser = new CommandLineParser("assembly.dll", "--parameter", "key=value", "--parameter", "otherKey=valueContaining=EqualSign"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Keys.ShouldEqual("key", "otherKey"); parser.Options["key"].ShouldEqual("value"); parser.Options["otherKey"].ShouldEqual("valueContaining=EqualSign"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }
public void ParsesOptionNamesCaseInsensitive() { var parser = new CommandLineParser("assembly.dll", "--nUnItXmL", "NUnit.xml", "--XuNiTxMl", "XUnit.xml", "--tEaMcItY", "off", "--pArAmEtEr", "key=value"); parser.AssemblyPaths.ShouldEqual("assembly.dll"); parser.Options.Keys.OrderBy(x => x).ShouldEqual("key", "NUnitXml", "TeamCity", "XUnitXml"); parser.Options["key"].ShouldEqual("value"); parser.Options["NUnitXml"].ShouldEqual("NUnit.xml"); parser.Options["TeamCity"].ShouldEqual("off"); parser.Options["XUnitXml"].ShouldEqual("XUnit.xml"); parser.HasErrors.ShouldBeFalse(); parser.Errors.ShouldBeEmpty(); }