Skip to content

Finalize Test tasks with JacocoReport and JacocoCoverageVerification tasks

License

Notifications You must be signed in to change notification settings

remal-gradle-plugins/finalize-by-jacoco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tested on Java LTS versions from 8 to 21.

Tested on Gradle versions from 6.0 to 8.12.

name.remal.finalize-by-jacoco plugin

configuration cache: supported

Usage:

plugins {
    id 'name.remal.finalize-by-jacoco' version '1.0.5'
}

 

By default, Gradle doesn't make Jacoco tasks executed automatically. This plugin fixes this.

This plugin applies jacoco plugin and then makes Test task finalized by corresponding JacocoReport and JacocoCoverageVerification tasks.

Also, JacocoReport and JacocoCoverageVerification become depend on the corresponding Test task.

Example:

  • test is finalized by jacocoTestReport and jacocoTestCoverageVerification tasks
  • if a user executes jacocoTestReport task, test will also be executed
  • if a user executes jacocoTestCoverageVerification task, test will also be executed

Additional types of tests

Additional test source sets are also supported. See jvm-test-suite, name.remal.test-source-sets, and similar plugins.

Example:

testing.suites {
  test {
    useJUnitJupiter()
  }

  integrationTest(JvmTestSuite) {
  }
}
  • integrationTest is finalized by jacocoIntegrationTestReport and jacocoIntegrationTestCoverageVerification tasks
  • if a user executes jacocoIntegrationTestReport task, integrationTest will also be executed
  • if a user executes jacocoIntegrationTestCoverageVerification task, integrationTest will also be executed

How the plugin matches tasks

If a task has JacocoTaskExtension extension, Jacoco tasks that work with the same Jacoco execution data file will be matched.

If a Jacoco task works with multiple execution files, it won't be matched.