Skip to content

Commit

Permalink
Show message in HTML report when analyzed class does not match execut…
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin authored Jan 6, 2019
1 parent c7d70c7 commit abb6f9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ <h3>New Features</h3>
(GitHub <a href="https://github.com/jacoco/jacoco/issues/801">#801</a>).</li>
<li>HTML report shows message when class has no debug information
(GitHub <a href="https://github.com/jacoco/jacoco/issues/818">#818</a>).</li>
<li>HTML report shows message when analyzed class does not match executed
(GitHub <a href="https://github.com/jacoco/jacoco/issues/819">#819</a>).</li>
</ul>

<h3>Fixed Bugs</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ public void should_generate_message_when_no_lines() throws Exception {
support.findStr(doc, "/html/body/p[1]"));
}

@Test
public void should_generate_message_when_class_id_mismatch()
throws Exception {
node = new ClassCoverageImpl("Foo", 123, true);
node.addMethod(new MethodCoverageImpl("m", "()V", null));

page = new ClassPage(node, null, new SourceLink(), rootFolder, context);
page.render();

final Document doc = support.parse(output.getFile("Foo.html"));
assertEquals("A different version of class was executed at runtime.",
support.findStr(doc, "/html/body/p[1]"));
}

private class SourceLink implements ILinkable {

public String getLink(final ReportOutputFolder base) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public String getLinkLabel() {

@Override
protected void content(HTMLElement body) throws IOException {
if (getNode().isNoMatch()) {
body.p().text(
"A different version of class was executed at runtime.");
}

if (getNode().getLineCounter().getTotalCount() == 0) {
body.p().text(
"Class files must be compiled with debug information to show line coverage.");
Expand Down

0 comments on commit abb6f9a

Please sign in to comment.