public XDocument Transform(ExecutionResult executionResult) { var now = DateTime.UtcNow; var assemblyResult = executionResult.AssemblyResults.Single(); var @assembly = new XElement("assembly", new XAttribute("name", assemblyResult.Name), new XAttribute("run-date", now.ToString("yyyy-MM-dd")), new XAttribute("run-time", now.ToString("HH:mm:ss")), new XAttribute("configFile", AppDomain.CurrentDomain.SetupInformation.ConfigurationFile), new XAttribute("time", GetTime(assemblyResult.Duration)), new XAttribute("total", assemblyResult.Total), new XAttribute("passed", assemblyResult.Passed), new XAttribute("failed", assemblyResult.Failed), new XAttribute("skipped", assemblyResult.Skipped), new XAttribute("environment", string.Format("{0}-bit .NET {1}", Environment.Is64BitProcess ? "64" : "32", Assembly.ReflectionOnlyLoadFrom(assemblyResult.Name).ImageRuntimeVersion)), new XAttribute("test-framework", string.Format("fixie {0}", Assembly.GetExecutingAssembly().GetName().Version))); foreach (var classResult in assemblyResult.ConventionResults.SelectMany(x => x.ClassResults)) @assembly.Add(ClassElement(classResult)); return new XDocument(@assembly); }
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("Usage: Fixie.Console [custom-options] assembly-path..."); return FatalError; } var executionResult = new ExecutionResult(); var stopwatch = new Stopwatch(); stopwatch.Start(); foreach (var assemblyPath in commandLineParser.AssemblyPaths) { if (assemblyPath.ToLowerInvariant().EndsWith(".dll")) { executionResult.Add(Execute(assemblyPath, args)); } else { var fullPath = Path.GetFullPath(assemblyPath); var dir = new DirectoryInfo(fullPath); var assemblies = dir.EnumerateFiles("*.dll").Select(x => x.FullName); foreach (var assembly in assemblies) { executionResult.Add(Execute(assembly, args)); } } } 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 XDocument Transform(ExecutionResult executionResult) { var now = DateTime.UtcNow; return new XDocument( new XElement("test-results", new XAttribute("date", now.ToString("yyyy-MM-dd")), new XAttribute("time", now.ToString("HH:mm:ss")), new XAttribute("name", "Results"), new XAttribute("total", executionResult.Total), new XAttribute("failures", executionResult.Failed), new XAttribute("not-run", executionResult.Skipped), executionResult.AssemblyResults.Select(Assembly))); }
public void ShouldProduceValidXmlDocument() { var listener = new StubListener(); var runner = new Runner(listener); var executionResult = new ExecutionResult(); var convention = new SelfTestConvention(); convention.CaseExecution.Skip(x => x.Method.Has<SkipAttribute>(), x => x.Method.GetCustomAttribute<SkipAttribute>().Reason); var assemblyResult = runner.RunType(GetType().Assembly, convention, typeof(PassFailTestClass)); executionResult.Add(assemblyResult); var report = new NUnitXmlReport(); var actual = report.Transform(executionResult); XsdValidate(actual); CleanBrittleValues(actual.ToString(SaveOptions.DisableFormatting)).ShouldEqual(ExpectedReport); }
public XDocument Transform(ExecutionResult executionResult) { var now = DateTime.UtcNow; var root = new XElement("test-results", new XAttribute("date", now.ToString("yyyy-MM-dd")), new XAttribute("time", now.ToString("HH:mm:ss")), new XAttribute("name", "Results"), new XAttribute("total", executionResult.Total), new XAttribute("failures", executionResult.Failed), new XAttribute("not-run", executionResult.Skipped)); foreach (var assemblyResult in executionResult.AssemblyResults) root.Add(TestSuiteElement(assemblyResult)); return new XDocument(root); }
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("Usage: Fixie.Console [custom-options] assembly-path..."); return FatalError; } var executionResult = new ExecutionResult(); var stopwatch = new Stopwatch(); stopwatch.Start(); foreach (var assemblyPath in commandLineParser.AssemblyPaths) { var result = Execute(assemblyPath, args); 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; } }
static void ProduceReports(ILookup<string, string> options, ExecutionResult executionResult) { if (options.Contains(CommandLineOption.NUnitXml)) { var report = new NUnitXmlReport(); var xDocument = report.Transform(executionResult); foreach (var fileName in options[CommandLineOption.NUnitXml]) xDocument.Save(fileName, SaveOptions.None); } if (options.Contains(CommandLineOption.XUnitXml)) { var report = new XUnitXmlReport(); var xDocument = report.Transform(executionResult); foreach (var fileName in options[CommandLineOption.XUnitXml]) xDocument.Save(fileName, SaveOptions.None); } }
static void Summarize(ExecutionResult executionResult, TimeSpan elapsed) { var line = new StringBuilder(); line.AppendFormat("{0} passed", executionResult.Passed); line.AppendFormat(", {0} failed", executionResult.Failed); if (executionResult.Skipped > 0) line.AppendFormat(", {0} skipped", executionResult.Skipped); line.AppendFormat(", took {0:N2} seconds", elapsed.TotalSeconds); Console.WriteLine("====== Total Tests: " + line + " ======"); }
public XDocument Transform(ExecutionResult executionResult) { return new XDocument( new XElement("assemblies", executionResult.AssemblyResults.Select(Assembly))); }