jacocoTestReport task's behaviour


(Behrang Saeedzadeh) #1

Hi,

In the docs, it is mentioned that:

If the Java plugin is also applied to your project, a new task named jacocoTestReport is created that depends on the test task

However, running:

./gradlew clean jacocoTestReport

Doesn’t run any tests and doesn’t generate any reports:

 $ ./gradlew clean jacocoTestReport --dry-run
:clean SKIPPED
:compileJava SKIPPED
:processResources SKIPPED
:classes SKIPPED
:jacocoTestReport SKIPPED

Looks like this is a known issue and discussed in the past (Dec 2013), but is not addressed yet.

Consequently the only way to run jacoco and check against violation rules is:

$ ./gradlew clean build jacocoTestReport jacocoTestCoverageVerification

which is quite verbose.

One way to make jacocoTestReport and jacocoTestCoverageVerification run after test, is declare the following dependencies:

test.finalizedBy jacocoTestReport
jacocoTestReport.finalizedBy jacocoTestCoverageVerification

Either the doc should be updated to reflect this, or the implementation should change to align with the docs.