use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class ClassRowWriter method writeRow.
/**
* Writes the class summary information as a row.
*
* @param groupName
* name of the group
* @param packageName
* vm name of the package
* @param node
* class coverage data
* @throws IOException
* in case of problems with the writer
*/
public void writeRow(final String groupName, final String packageName, final IClassCoverage node) throws IOException {
writer.write(groupName);
writer.write(languageNames.getPackageName(packageName));
final String className = languageNames.getClassName(node.getName(), node.getSignature(), node.getSuperName(), node.getInterfaceNames());
writer.write(className);
for (final CounterEntity entity : COUNTERS) {
final ICounter counter = node.getCounter(entity);
writer.write(counter.getMissedCount());
writer.write(counter.getCoveredCount());
}
writer.nextLine();
}
use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class SourceHighlighter method highlight.
HTMLElement highlight(final HTMLElement pre, final ILine line, final int lineNr) throws IOException {
final String style;
switch(line.getStatus()) {
case ICounter.NOT_COVERED:
style = Styles.NOT_COVERED;
break;
case ICounter.FULLY_COVERED:
style = Styles.FULLY_COVERED;
break;
case ICounter.PARTLY_COVERED:
style = Styles.PARTLY_COVERED;
break;
default:
return pre;
}
final String lineId = "L" + Integer.toString(lineNr);
final ICounter branches = line.getBranchCounter();
switch(branches.getStatus()) {
case ICounter.NOT_COVERED:
return span(pre, lineId, style, Styles.BRANCH_NOT_COVERED, "All %2$d branches missed.", branches);
case ICounter.FULLY_COVERED:
return span(pre, lineId, style, Styles.BRANCH_FULLY_COVERED, "All %2$d branches covered.", branches);
case ICounter.PARTLY_COVERED:
return span(pre, lineId, style, Styles.BRANCH_PARTLY_COVERED, "%1$d of %2$d branches missed.", branches);
default:
return pre.span(style, lineId);
}
}
use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class BarColumn method footer.
public void footer(final HTMLElement td, final ICoverageNode total, final Resources resources, final ReportOutputFolder base) throws IOException {
final ICounter counter = total.getCounter(entity);
td.text(integerFormat.format(counter.getMissedCount())).text(" of ").text(integerFormat.format(counter.getTotalCount()));
}
use of org.jacoco.core.analysis.ICounter in project jacoco by jacoco.
the class XMLCoverageWriter method writeCounters.
/**
* Writes all non-zero counters of the given node.
*
* @param node
* node to retrieve counters from
* @param parent
* container for the counter elements
* @throws IOException
* if XML can't be written to the underlying output
*/
public static void writeCounters(final ICoverageNode node, final XMLElement parent) throws IOException {
for (final CounterEntity counterEntity : CounterEntity.values()) {
final ICounter counter = node.getCounter(counterEntity);
if (counter.getTotalCount() > 0) {
final XMLElement counterNode = parent.element("counter");
counterNode.attr("type", counterEntity.name());
writeCounter(counterNode, "missed", "covered", counter);
counterNode.close();
}
}
}
use of org.jacoco.core.analysis.ICounter in project sonar-java by SonarSource.
the class UnitTestAnalyzer method analyzeFile.
private static void analyzeFile(NewCoverage newCoverage, InputFile resource, ISourceFileCoverage coverage) {
for (int lineId = coverage.getFirstLine(); lineId <= coverage.getLastLine(); lineId++) {
final int hits;
ILine line = coverage.getLine(lineId);
switch(line.getInstructionCounter().getStatus()) {
case ICounter.FULLY_COVERED:
case ICounter.PARTLY_COVERED:
hits = 1;
break;
case ICounter.NOT_COVERED:
hits = 0;
break;
case ICounter.EMPTY:
continue;
default:
JaCoCoExtensions.LOG.warn("Unknown status for line {} in {}", lineId, resource);
continue;
}
newCoverage.lineHits(lineId, hits);
ICounter branchCounter = line.getBranchCounter();
int conditions = branchCounter.getTotalCount();
if (conditions > 0) {
int coveredConditions = branchCounter.getCoveredCount();
newCoverage.conditions(lineId, conditions, coveredConditions);
}
}
}
Aggregations