Author: shane.bryzak(a)jboss.com
Date: 2009-02-18 20:11:40 -0500 (Wed, 18 Feb 2009)
New Revision: 15999
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
Log:
added table of contents, minor
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
===================================================================
---
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-18
15:50:13 UTC (rev 15998)
+++
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-19
01:11:40 UTC (rev 15999)
@@ -68,7 +68,8 @@
auditParser.parse();
}
catch (Exception e) {
- throw new RuntimeException("Unable to parse audit file.");
+ e.printStackTrace();
+ throw new RuntimeException("Unable to parse audit file.", e);
}
}
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
---
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-18
15:50:13 UTC (rev 15998)
+++
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-19
01:11:40 UTC (rev 15999)
@@ -34,6 +34,8 @@
private String fisheyeBaseUrl = null;
private String svnBaseUrl = null;
+
+ private List<SpecReference> unmatched;
public CoverageReport(List<SpecReference> references, AuditParser auditParser)
{
this.references = new HashMap<String, List<SpecReference>>();
@@ -73,14 +75,29 @@
}
public void generate(OutputStream out) throws IOException {
+ calculateUnmatched();
writeHeader(out);
+ writeContents(out);
writeMasterSummary(out);
writeSectionSummary(out);
writeCoverage(out);
writeUnmatched(out);
writeFooter(out);
}
+
+ private void calculateUnmatched()
+ {
+ unmatched = new ArrayList<SpecReference>();
+ for (String sectionId : references.keySet()) {
+ for (SpecReference ref : references.get(sectionId)) {
+ if (!auditParser.hasAssertion(ref.getSection(), ref.getAssertion())) {
+ unmatched.add(ref);
+ }
+ }
+ }
+ }
+
private void writeHeader(OutputStream out) throws IOException {
StringBuilder sb = new StringBuilder();
@@ -150,10 +167,22 @@
out.write(sb.toString().getBytes());
}
+ private void writeContents(OutputStream out) throws IOException {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("<h3>Contents</h3>");
+ sb.append("<div><a href=\"#masterSummary\">Master
Summary</a></div>");
+ sb.append("<div><a href=\"#sectionSummary\">Section
Summary</a></div>");
+ sb.append("<div><a href=\"#coverageDetail\">Coverage
Detail</a></div>");
+ sb.append("<div><a href=\"#unmatched\">Unmatched
Tests</a></div>");
+
+ out.write(sb.toString().getBytes());
+ }
+
private void writeMasterSummary(OutputStream out) throws IOException {
StringBuilder sb = new StringBuilder();
- sb.append("<h3>Master Summary</h3>\n");
+ sb.append("<h3 id=\"masterSummary\">Master
Summary</h3>\n");
sb.append("<table border=\"0\">");
@@ -198,12 +227,25 @@
sb.append("<td>Total percentage of tested
assertions</td>");
double coveragePercent = assertionTotal > 0 ? ((coverage * 1.0) /
assertionTotal) * 100 : 0;
- sb.append("<td>");
+
+ String bgColor = coveragePercent < 60 ? "#ffaaaa" : coveragePercent
< 80 ? "#ffffaa" : "#aaffaa";
+
+ sb.append("<td align=\"center\"
style=\"background-color:" + bgColor + "\">");
+
sb.append(String.format("%.2f%%", coveragePercent));
sb.append("</td>");
- sb.append("</tr>");
+ sb.append("</tr>");
+ sb.append("<tr>");
+ sb.append("<td>Total number of unmatched tests</td>");
+
+ sb.append("<td>");
+ sb.append(unmatched.size());
+ sb.append("</td>");
+
+ sb.append("</tr>");
+
sb.append("</table>");
out.write(sb.toString().getBytes());
@@ -212,7 +254,7 @@
private void writeSectionSummary(OutputStream out) throws IOException {
StringBuilder sb = new StringBuilder();
- sb.append("<h3>Section Summary</h3>\n");
+ sb.append("<h3 id=\"sectionSummary\">Section
Summary</h3>\n");
sb.append("<table width=\"100%\">");
@@ -284,7 +326,7 @@
private void writeCoverage(OutputStream out) throws IOException {
- out.write("<h3>Coverage Detail</h3>\n".getBytes());
+ out.write("<h3 id=\"coverageDetail\">Coverage
Detail</h3>\n".getBytes());
for (String sectionId : auditParser.getSectionIds()) {
@@ -375,21 +417,11 @@
}
private void writeUnmatched(OutputStream out) throws IOException {
- List<SpecReference> unmatched = new ArrayList<SpecReference>();
-
- for (String sectionId : references.keySet()) {
- for (SpecReference ref : references.get(sectionId)) {
- if (!auditParser.hasAssertion(ref.getSection(), ref.getAssertion())) {
- unmatched.add(ref);
- }
- }
- }
-
if (unmatched.isEmpty()) return;
StringBuilder sb = new StringBuilder();
- sb.append("<h3>Unmatched tests</h3>\n");
+ sb.append("<h3 id=\"unmatched\">Unmatched
tests</h3>\n");
sb.append(String.format("<p>The following %d tests do not match any
known assertions:</p>",
unmatched.size()));
Show replies by date