apply plugin: 'jacoco' dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}" testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}" } def jacocoTestReport = tasks.named('jacocoTestReport') jacocoTestReport.configure { dependsOn test reports { xml.required = true } } tasks.named('test') { useJUnitPlatform { excludeTags 'slow' } finalizedBy jacocoTestReport } tasks.register('slowTest', Test) { useJUnitPlatform() finalizedBy jacocoTestReport }