jacoco-maven-plugin: Including test sources/classes in report

63 views
Skip to first unread message

Andreas Sewe

unread,
Dec 14, 2018, 5:38:35 AM12/14/18
to jac...@googlegroups.com
Hi all,

is it possible at the moment to include the test sources/classes in the
reported generated by jacoco-maven-plugin:report?

AFAICT from the jacoco.exec, the test classes have probes inserted in
them, but the generated reports only show code from src/main/java (and
other registered source directories), but not from src/test/java.

Is there some way to include them in the report? (Use case: Spotting
tests that are not executed, e.g., due to a missing @Test annotation or
not matching Maven's **Test.java naming convention.)

Best wishes,

Andreas

--
Dr. Andreas Sewe | se...@cqse.eu | +49 152 56342856
CQSE GmbH | Lichtenbergstrasse 8 | 85748 Garching | www.cqse.eu
Amtsgericht Muenchen | HRB 177678 | GF: F. Deissenboeck, M. Feilkas

signature.asc

Evgeny Mandrikov

unread,
Dec 14, 2018, 7:28:10 AM12/14/18
to JaCoCo and EclEmma Users
Hi Andreas,


On Friday, December 14, 2018 at 11:38:35 AM UTC+1, Andreas Sewe wrote:
Hi all,

is it possible at the moment to include the test sources/classes in the
reported generated by jacoco-maven-plugin:report?

No, it is not possible with jacoco-maven-plugin:report
 
AFAICT from the jacoco.exec, the test classes have probes inserted in
them, but the generated reports only show code from src/main/java (and
other registered source directories), but not from src/test/java.

Is there some way to include them in the report? (Use case: Spotting
tests that are not executed, e.g., due to a missing @Test annotation or
not matching Maven's **Test.java naming convention.)

To achieve this you can use JaCoCo Ant Task report ( https://www.jacoco.org/jacoco/trunk/doc/ant.html ) via maven-antrun-plugin

Andreas Sewe

unread,
Dec 14, 2018, 9:08:08 AM12/14/18
to jac...@googlegroups.com
Hi Evgeny,

thanks for the quick reply.

you wrote:
> On Friday, December 14, 2018 at 11:38:35 AM UTC+1, Andreas Sewe wrote:
> is it possible at the moment to include the test sources/classes in the
> reported generated by jacoco-maven-plugin:report?
>
>
> No, it is not possible with jacoco-maven-plugin:report

Worth filing a feature request? A couple of similar plugins [1, 2]
already have an option along the line of <includeTestSources>.

Briefly looking at the code [3, 4], the required code changes for this
feature should be fairly minimal.

> AFAICT from the jacoco.exec, the test classes have probes inserted in
> them, but the generated reports only show code from src/main/java (and
> other registered source directories), but not from src/test/java.
>
> Is there some way to include them in the report? (Use case: Spotting
> tests that are not executed, e.g., due to a missing @Test annotation or
> not matching Maven's **Test.java naming convention.)
>
>
> To achieve this you can use JaCoCo Ant Task report
> ( https://www.jacoco.org/jacoco/trunk/doc/ant.html ) via maven-antrun-plugin

OK, will have a look at the Ant task for now.

Best wishes,

Andreas

[1]
<https://maven.apache.org/plugins/maven-checkstyle-plugin/check-mojo.html#includeTestSourceDirectory>
[2]
<https://spotbugs.github.io/spotbugs-maven-plugin/check-mojo.html#includeTests>
[1]
<https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin/src/org/jacoco/maven/ReportSupport.java#L192>
[2]
<https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin/src/org/jacoco/maven/ReportSupport.java#L277>
signature.asc

Evgeny Mandrikov

unread,
Dec 14, 2018, 9:12:45 AM12/14/18
to JaCoCo and EclEmma Users


On Friday, December 14, 2018 at 3:08:08 PM UTC+1, Andreas Sewe wrote:
Hi Evgeny,

thanks for the quick reply.

you wrote:
> On Friday, December 14, 2018 at 11:38:35 AM UTC+1, Andreas Sewe wrote:
>     is it possible at the moment to include the test sources/classes in the
>     reported generated by jacoco-maven-plugin:report?
>
>
> No, it is not possible with jacoco-maven-plugin:report

Worth filing a feature request? A couple of similar plugins [1, 2]
already have an option along the line of <includeTestSources>.

Briefly looking at the code [3, 4], the required code changes for this
feature should be fairly minimal.

Andreas Sewe

unread,
Dec 14, 2018, 9:34:05 AM12/14/18
to jac...@googlegroups.com
Evgeny Mandrikov wrote:
> Ticket already exists - https://github.com/jacoco/jacoco/issues/271

Good to know.

Given that the PR is from 2015, is there anything I can do to speed this
along, e.g., only introducing <includeTests> without the (distinct)
report selection feature? For example, creating another PR?

Best wishes,

Andreas
signature.asc

Evgeny Mandrikov

unread,
Dec 14, 2018, 11:03:08 AM12/14/18
to JaCoCo and EclEmma Users


On Friday, December 14, 2018 at 3:34:05 PM UTC+1, Andreas Sewe wrote:
Evgeny Mandrikov wrote:
> Ticket already exists - https://github.com/jacoco/jacoco/issues/271

Good to know.

Given that the PR is from 2015, is there anything I can do to speed this
along, e.g., only introducing <includeTests> without the (distinct)
report selection feature? For example, creating another PR?
 
To help us consider addition of such feature and its design,
please just add comment with links to other plugins that you provided earlier in this thread.


Thanks,
Evgeny

Andreas Sewe

unread,
Dec 17, 2018, 3:23:20 AM12/17/18
to jac...@googlegroups.com
Evgeny Mandrikov wrote:
> To help us consider addition of such feature and its design,
> please just add comment with links to other plugins that you provided
> earlier in this thread.
Done: https://github.com/jacoco/jacoco/issues/271.

Also mentioned having a separate goal (test-report) as an alternative
solution.

Hope this helps,
signature.asc
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages