use of org.jacoco.core.analysis.IClassCoverage in project jacoco by jacoco.
the class BundleCheckerTest method createBundle.
private IBundleCoverage createBundle() {
final MethodCoverageImpl m = new MethodCoverageImpl("fooMethod", "()V", null);
m.increment(CounterImpl.getInstance(5, 5), CounterImpl.COUNTER_0_0, 1);
m.incrementMethodCounter();
final ClassCoverageImpl c = new ClassCoverageImpl("org/jacoco/example/FooClass", 1001, false);
c.setSourceFileName("FooClass.java");
c.addMethod(m);
final SourceFileCoverageImpl s = new SourceFileCoverageImpl("FooClass.java", "org/jacoco/example");
s.increment(c);
IPackageCoverage p = new PackageCoverageImpl("org/jacoco/example", Collections.singleton((IClassCoverage) c), Collections.singleton((ISourceFileCoverage) s));
return new BundleCoverageImpl("Test", Collections.singleton(p));
}
use of org.jacoco.core.analysis.IClassCoverage in project jacoco by jacoco.
the class ClassRowWriterTest method TestRow.
@Test
public void TestRow() throws Exception {
IClassCoverage node = new ClassCoverageImpl("test/package/Foo", 123, false) {
{
instructionCounter = CounterImpl.getInstance(1, 11);
branchCounter = CounterImpl.getInstance(2, 22);
lineCounter = CounterImpl.getInstance(3, 33);
complexityCounter = CounterImpl.getInstance(4, 44);
methodCounter = CounterImpl.getInstance(5, 55);
classCounter = CounterImpl.getInstance(6, 66);
}
};
writer.writeRow("group", "test/package", node);
BufferedReader reader = getResultReader();
reader.readLine();
assertEquals("group,test/package,test/package/Foo,1,11,2,22,3,33,4,44,5,55", reader.readLine());
}
use of org.jacoco.core.analysis.IClassCoverage in project jacoco by jacoco.
the class AnalysisTimeScenario method getInstrumentedCallable.
@Override
protected Callable<Void> getInstrumentedCallable() throws Exception {
final byte[] bytes = TargetLoader.getClassDataAsBytes(target);
final ExecutionDataStore executionData = new ExecutionDataStore();
ICoverageVisitor visitor = new ICoverageVisitor() {
public void visitCoverage(IClassCoverage coverage) {
}
};
final Analyzer analyzer = new Analyzer(executionData, visitor);
return new Callable<Void>() {
public Void call() throws Exception {
for (int i = 0; i < count; i++) {
analyzer.analyzeClass(bytes, target.getName());
}
return null;
}
};
}
use of org.jacoco.core.analysis.IClassCoverage in project jacoco by jacoco.
the class BundleChecker method check.
private void check(final IPackageCoverage packageCoverage) {
final String name = names.getPackageName(packageCoverage.getName());
checkRules(packageCoverage, packageRules, "package", name);
if (traverseClasses) {
for (final IClassCoverage c : packageCoverage.getClasses()) {
check(c);
}
}
if (traverseSourceFiles) {
for (final ISourceFileCoverage s : packageCoverage.getSourceFiles()) {
check(s);
}
}
}
use of org.jacoco.core.analysis.IClassCoverage in project sonar-java by SonarSource.
the class JacocoReportReader method logNoMatchClasses.
private static void logNoMatchClasses(Collection<IClassCoverage> noMatchClasses) {
if (noMatchClasses.isEmpty()) {
return;
}
LOG.warn("The following class(es) did not match with execution data:");
for (IClassCoverage iClassCoverage : noMatchClasses) {
LOG.warn(String.format("> '%s'", iClassCoverage.getName()));
}
LOG.warn("In order to have accurate coverage measures, the same class files must be used as at runtime for report generation.");
}
Aggregations