/// <summary> /// Emits all the testing coverage related output files. /// </summary> /// <param name="report">TestReport containing CoverageInfo</param> /// <param name="directory">Output directory name, unique for this run</param> /// <param name="file">Output file name</param> private static void EmitTestingCoverageOutputFiles(TestReport report, string directory, string file) { var codeCoverageReporter = new ActivityCoverageReporter(report.CoverageInfo); var filePath = $"{directory}{file}"; string graphFilePath = $"{filePath}.dgml"; Console.WriteLine($"..... Writing {graphFilePath}"); codeCoverageReporter.EmitVisualizationGraph(graphFilePath); string coverageFilePath = $"{filePath}.coverage.txt"; Console.WriteLine($"..... Writing {coverageFilePath}"); codeCoverageReporter.EmitCoverageReport(coverageFilePath); string serFilePath = $"{filePath}.sci"; Console.WriteLine($"..... Writing {serFilePath}"); report.CoverageInfo.Save(serFilePath); }
private static void Main(string[] args) { if (!TryParseArgs(args, out List <CoverageInfo> inputFiles)) { return; } if (inputFiles.Count == 0) { Console.WriteLine("Error: No input files provided"); return; } var cinfo = new CoverageInfo(); foreach (var other in inputFiles) { cinfo.Merge(other); } // Dump string name = OutputFilePrefix; string directoryPath = Environment.CurrentDirectory; var activityCoverageReporter = new ActivityCoverageReporter(cinfo); string[] graphFiles = Directory.GetFiles(directoryPath, name + "_*.dgml"); string graphFilePath = Path.Combine(directoryPath, name + "_" + graphFiles.Length + ".dgml"); Console.WriteLine($"... Writing {graphFilePath}"); activityCoverageReporter.EmitVisualizationGraph(graphFilePath); string[] coverageFiles = Directory.GetFiles(directoryPath, name + "_*.coverage.txt"); string coverageFilePath = Path.Combine(directoryPath, name + "_" + coverageFiles.Length + ".coverage.txt"); Console.WriteLine($"... Writing {coverageFilePath}"); activityCoverageReporter.EmitCoverageReport(coverageFilePath); }
/// <summary> /// Emits all the testing coverage related output files. /// </summary> /// <param name="report">TestReport containing CoverageInfo</param> /// <param name="directory">Output directory name, unique for this run</param> /// <param name="file">Output file name</param> private static void EmitTestingCoverageOutputFiles(TestReport report, string directory, string file) { var codeCoverageReporter = new ActivityCoverageReporter(report.CoverageInfo); var filePath = $"{directory}{file}"; string graphFilePath = $"{filePath}.dgml"; Output.WriteLine($"..... Writing {graphFilePath}"); codeCoverageReporter.EmitVisualizationGraph(graphFilePath); string coverageFilePath = $"{filePath}.coverage.txt"; Output.WriteLine($"..... Writing {coverageFilePath}"); codeCoverageReporter.EmitCoverageReport(coverageFilePath); string serFilePath = $"{filePath}.sci"; Output.WriteLine($"..... Writing {serFilePath}"); using (var fs = new FileStream(serFilePath, FileMode.Create)) { var serializer = new DataContractSerializer(typeof(CoverageInfo)); serializer.WriteObject(fs, report.CoverageInfo); } }
/// <summary> /// Tries to emit the available coverage reports to the specified directory with the given file name, /// and returns the paths of all emitted coverage reports. /// </summary> public bool TryEmitCoverageReports(string directory, string fileName, out IEnumerable <string> reportPaths) { var paths = new List <string>(); if (this.Configuration.IsActivityCoverageReported) { var codeCoverageReporter = new ActivityCoverageReporter(this.TestReport.CoverageInfo); string graphFilePath = Path.Combine(directory, fileName + ".coverage.dgml"); codeCoverageReporter.EmitVisualizationGraph(graphFilePath); paths.Add(graphFilePath); string coverageFilePath = Path.Combine(directory, fileName + ".coverage.txt"); codeCoverageReporter.EmitCoverageReport(coverageFilePath); paths.Add(coverageFilePath); string serFilePath = Path.Combine(directory, fileName + ".sci"); this.TestReport.CoverageInfo.Save(serFilePath); paths.Add(serFilePath); } reportPaths = paths; return(paths.Count > 0); }