public static void WriteMissingReqReport(string outputFolderPath) { StringBuilder sb = new StringBuilder(); int count = 0; // Print table header. sb.AppendLine("Requirement ID,Reason,Found in,Line Number"); // Find all requirements with invalid identfiers in code or tests. foreach (string key in ReportGenerator.invalidRequirements.Keys) { foreach (InvalidReqDictEntry entry in ReportGenerator.invalidRequirements[key]) { sb.AppendLine(key + "," + entry.reason + "," + entry.filePath + "," + entry.lineNum.ToString()); } } // Find all requirements not covered in code. foreach (string key in ReportGenerator.missingCodeCoverage.Keys) { // Check if the requirement is also not covered in tests. if (ReportGenerator.missingTestCoverage.ContainsKey(key)) { sb.AppendLine(key + ",Not coded and not tested," + ReportGenerator.missingCodeCoverage[key]); count++; } else { sb.AppendLine(key + ",Not coded," + ReportGenerator.missingCodeCoverage[key]); } } // Find all the requirements not covered in tests. foreach (string key in ReportGenerator.missingTestCoverage.Keys) { // Ignore the requirements that we already found missing in code. if (!ReportGenerator.missingCodeCoverage.ContainsKey(key)) { sb.AppendLine(key + ",Not tested," + ReportGenerator.missingTestCoverage[key]); } } sb.AppendLine("Total invalid requirements found in code and tests," + ReportGenerator.invalidRequirements.Count.ToString()); sb.AppendLine("Total unimplemented requirements," + ReportGenerator.missingCodeCoverage.Count.ToString()); sb.AppendLine("Total untested requirements," + ReportGenerator.missingTestCoverage.Count.ToString()); sb.AppendLine("Total requirements missing both implementation and tests," + count.ToString()); // Output data to a CSV file. ReportWriter.writeStringToFile(sb.ToString(), outputFolderPath + @"\missing_requirements.csv"); }
public static void WriteTraceabilityReport(string outputFolderPath) { StringBuilder sb = new StringBuilder(); // Print table header. sb.AppendLine("Requirement ID,,File Name,Line Number"); // Check every requiremend ID extracted from requirement documents. foreach (string key in ReportGenerator.reqDocLookup.Keys) { // Print requirement ID and the path of the document defining it. sb.AppendLine(key + ",Defined in," + ReportGenerator.reqDocLookup[key]); // Print source code file paths if (ReportGenerator.reqCodeMatrix.ContainsKey(key)) { foreach (FilePathLineNum reqData in ReportGenerator.reqCodeMatrix[key]) { sb.AppendLine(key + ",Coded in," + reqData.filePath + "," + reqData.lineNum.ToString()); } } else { sb.AppendLine(key + ",Not coded," + Path.GetFileName(ReportGenerator.reqDocLookup[key])); } // Print test code file paths if (ReportGenerator.reqTestMatrix.ContainsKey(key)) { foreach (FilePathLineNum reqData in ReportGenerator.reqTestMatrix[key]) { sb.AppendLine(key + ",Tested in," + reqData.filePath + "," + reqData.lineNum.ToString()); } } else { sb.AppendLine(key + ",Not tested," + Path.GetFileName(ReportGenerator.reqDocLookup[key])); } } // Print totals sb.AppendLine("Total unique requirements," + ReportGenerator.reqDocLookup.Count.ToString()); sb.AppendLine("Total implemented requirements," + ReportGenerator.reqCodeMatrix.Count.ToString()); sb.AppendLine("Total tested requirements," + ReportGenerator.reqTestMatrix.Count.ToString()); sb.AppendLine("Total unimplemented requirements," + ReportGenerator.missingCodeCoverage.Count.ToString()); sb.AppendLine("Total untested requirements," + ReportGenerator.missingTestCoverage.Count.ToString()); // Output data to a CSV file. ReportWriter.writeStringToFile(sb.ToString(), outputFolderPath + @"\traceability_matrix.csv"); }
public static void WriteRepeatingReqReport(string outputFolderPath) { StringBuilder sb = new StringBuilder(); // Print table header. sb.AppendLine("Requirement ID,Found in File"); foreach (string key in ReportGenerator.repeatingRequirements.Keys) { foreach (string reqDocPath in ReportGenerator.repeatingRequirements[key]) { sb.AppendLine(key + "," + reqDocPath); } } sb.AppendLine("Total repeating requirements," + ReportGenerator.repeatingRequirements.Count.ToString()); // Output data to a CSV file. ReportWriter.writeStringToFile(sb.ToString(), outputFolderPath + @"\repeating_requirements.csv"); }
public static int GenerateReport(string rootFolderPath, string outputFolderPath, string[] exclusionDirs, MainForm mainForm) { // Clear the lists/dictionaries of files and requirement IDs in case we need to generate the reports again. requirementDocuments.Clear(); reqCodeLookup.Clear(); reqDocCount.Clear(); sourceCodeFiles.Clear(); repeatingRequirements.Clear(); invalidRequirements.Clear(); reqDocLookup.Clear(); reqCodeMatrix.Clear(); reqTestMatrix.Clear(); missingCodeCoverage.Clear(); missingTestCoverage.Clear(); int result = 0; // disable GUI elements if the program was called from command line interface. if (mainForm == null) { useGUI = false; } // output dir is an empty string if not valid. bool useOutputDir = (outputFolderPath.Length != 0); // Read requirement identifiers and file paths from word documents and source code files. GetRequirementsFromDocuments(rootFolderPath, exclusionDirs); // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(25); } GetRequirementsFromSource(rootFolderPath, exclusionDirs); // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(50); } GenerateTraceabilityMatrix(); // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(75); } FindUncoveredRequirements(); // Write all reports to plain text files if (MainForm.outputText && useOutputDir) { ReportWriter.WriteTraceabilityReport(outputFolderPath); ReportWriter.WriteInvalidReqReport(outputFolderPath); ReportWriter.WriteMissingCodeCoverageReport(outputFolderPath); ReportWriter.WriteMissingTestCoverageReport(outputFolderPath); ReportWriter.WriteMissingCodeAndTestCoverageReport(outputFolderPath); ReportWriter.WriteRepeatingReqReport(outputFolderPath); } // Write all reports to CSV files if (MainForm.outputCSV && useOutputDir) { CSVReportWriter.WriteTraceabilityReport(outputFolderPath); CSVReportWriter.WriteMissingReqReport(outputFolderPath); CSVReportWriter.WriteRepeatingReqReport(outputFolderPath); } if (MainForm.buildCheck) { result = ConsoleReportWriter.WriteMissingReqReport(); } // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(100); } return(result); }
public static void GenerateReport(string rootFolderPath, string outputFolderPath, MainForm mainForm) { // Clear the lists/dictionaries of files and requirement IDs in case we need to generate the reports again. requirementDocuments.Clear(); reqCodeLookup.Clear(); sourceCodeFiles.Clear(); repeatingRequirements.Clear(); invalidRequirements.Clear(); reqDocLookup.Clear(); reqCodeMatrix.Clear(); reqTestMatrix.Clear(); missingCodeCoverage.Clear(); missingTestCoverage.Clear(); // disable GUI elements if the program was called from command line interface. if (mainForm == null) { useGUI = false; } // Read requirement identifiers and file paths from word documents and source code files. GetRequirementsFromDocuments(rootFolderPath); // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(25); } GetRequirementsFromSource(rootFolderPath); // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(50); } GenerateTraceabilityMatrix(); // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(75); } FindUncoveredRequirements(); // Write all reports to plain text files if (MainForm.outputText) { ReportWriter.WriteTraceabilityReport(outputFolderPath); ReportWriter.WriteInvalidReqReport(outputFolderPath); ReportWriter.WriteMissingCodeCoverageReport(outputFolderPath); ReportWriter.WriteMissingTestCoverageReport(outputFolderPath); ReportWriter.WriteMissingCodeAndTestCoverageReport(outputFolderPath); ReportWriter.WriteRepeatingReqReport(outputFolderPath); } // Write all reports to CSV files if (MainForm.outputCSV) { CSVReportWriter.WriteTraceabilityReport(outputFolderPath); CSVReportWriter.WriteMissingReqReport(outputFolderPath); CSVReportWriter.WriteRepeatingReqReport(outputFolderPath); } // Update status on the progress bar if (mainForm != null) { mainForm.UpdateStatus(100); } }