in traceabilitytool/reportwriter.cs [15:82]
public static void WriteTraceabilityReport(string outputFolderPath)
{
StringBuilder sb = new StringBuilder();
foreach (string key in ReportGenerator.reqDocLookup.Keys)
{
// Print requirement ID.
sb.AppendLine(key);
// Print the path of the document where the requirement was defined.
sb.AppendLine(" Defined in: " + ReportGenerator.reqDocLookup[key]);
// Print source code file paths
bool firstLine = true;
if (ReportGenerator.reqCodeMatrix.ContainsKey(key))
{
foreach (FilePathLineNum reqData in ReportGenerator.reqCodeMatrix[key])
{
if (firstLine)
{
sb.AppendLine(" Coded in: " + reqData.filePath + ", line " + reqData.lineNum.ToString());
firstLine = false;
}
else
{
sb.AppendLine(" " + reqData.filePath + ", line " + reqData.lineNum.ToString());
}
}
}
else
{
sb.AppendLine(" Not Coded");
}
// Print test code file paths
if (ReportGenerator.reqTestMatrix.ContainsKey(key))
{
firstLine = true;
foreach (FilePathLineNum reqData in ReportGenerator.reqTestMatrix[key])
{
if (firstLine)
{
sb.AppendLine(" Tested in: " + reqData.filePath + ", line " + reqData.lineNum.ToString());
firstLine = false;
}
else
{
sb.AppendLine(" " + reqData.filePath + ", line " + reqData.lineNum.ToString());
}
}
}
else
{
sb.AppendLine(" Not Tested");
}
}
// Print totals
sb.AppendLine("".PadRight(42, '='));
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.
writeStringToFile(sb.ToString(), outputFolderPath + @"\traceability_matrix.txt");
}