use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.
the class ExecInfoTest method createExecFile.
private File createExecFile() throws IOException {
File f = new File(tmp.getRoot(), "test.exec");
final FileOutputStream out = new FileOutputStream(f);
final ExecutionDataWriter writer = new ExecutionDataWriter(out);
writer.visitSessionInfo(new SessionInfo("testid", 1, 2));
writer.visitClassExecution(new ExecutionData(0x1234, "foo/MyClass", new boolean[] { false, true, true }));
out.close();
return f;
}
use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.
the class ReportTest method should_print_warning_when_exec_data_does_not_match.
@Test
public void should_print_warning_when_exec_data_does_not_match() throws Exception {
File exec = new File(tmp.getRoot(), "jacoco.exec");
final FileOutputStream execout = new FileOutputStream(exec);
ExecutionDataWriter writer = new ExecutionDataWriter(execout);
// Add probably invalid id for this test class:
writer.visitClassExecution(new ExecutionData(0x123, getClass().getName().replace('.', '/'), new boolean[] { true }));
execout.close();
execute("report", exec.getAbsolutePath(), "--classfiles", getClassPath());
assertOk();
assertContains("[WARN] Some classes do not match with execution data.", out);
assertContains("[WARN] For report generation the same class files must be used as at runtime.", out);
assertContains("[WARN] Execution data for class org/jacoco/cli/internal/commands/ReportTest does not match.", out);
}
use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.
the class ExecDumpTest method createExecFile.
private String createExecFile() throws IOException {
File f = File.createTempFile("jacoco", ".exec");
final FileOutputStream out = new FileOutputStream(f);
final ExecutionDataWriter writer = new ExecutionDataWriter(out);
writer.visitSessionInfo(new SessionInfo("testid", 1, 2));
writer.visitClassExecution(new ExecutionData(0x1234, "foo/MyClass", new boolean[] { false, true, true }));
writer.flush();
out.close();
return f.getPath();
}
use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.
the class ExecDump method dump.
private void dump(final String file) throws IOException {
out.printf("exec file: %s%n", file);
out.println("CLASS ID HITS/PROBES CLASS NAME");
final FileInputStream in = new FileInputStream(file);
final ExecutionDataReader reader = new ExecutionDataReader(in);
reader.setSessionInfoVisitor(new ISessionInfoVisitor() {
public void visitSessionInfo(final SessionInfo info) {
out.printf("Session \"%s\": %s - %s%n", info.getId(), new Date(info.getStartTimeStamp()), new Date(info.getDumpTimeStamp()));
}
});
reader.setExecutionDataVisitor(new IExecutionDataVisitor() {
public void visitClassExecution(final ExecutionData data) {
out.printf("%016x %3d of %3d %s%n", Long.valueOf(data.getId()), Integer.valueOf(getHitCount(data.getProbes())), Integer.valueOf(data.getProbes().length), data.getName());
}
});
reader.read();
in.close();
out.println();
}
use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.
the class SessionsPageTest method testExecutionDataContent.
@Test
public void testExecutionDataContent() throws Exception {
final Collection<ExecutionData> data = new ArrayList<ExecutionData>();
data.add(new ExecutionData(0x1000, "ClassB", new boolean[0]));
data.add(new ExecutionData(0x1001, "ClassC", new boolean[0]));
data.add(new ExecutionData(0x1002, "ClassA", new boolean[0]));
index.addClass(new ReportPage(null, rootFolder, context) {
public String getLinkLabel() {
return "Foo";
}
@Override
protected String getFileName() {
return "Foo.html";
}
public String getLinkStyle() {
return "sample";
}
@Override
protected void content(HTMLElement body) throws IOException {
}
}, 0x1002);
final SessionsPage page = new SessionsPage(noSessions, data, index, null, rootFolder, context);
page.render();
final Document doc = support.parse(output.getFile("jacoco-sessions.html"));
assertEquals("el_class", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a/@class"));
assertEquals("Foo.html", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a/@href"));
assertEquals("ClassA", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a"));
assertEquals("0000000000001002", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[2]/code"));
assertEquals("ClassB", support.findStr(doc, "/html/body/table[1]/tbody/tr[2]/td[1]"));
assertEquals("ClassC", support.findStr(doc, "/html/body/table[1]/tbody/tr[3]/td[1]"));
}
Aggregations