'How to use Jacoco plugin along with JVM test suites plugin in Gradle?

We have a java project which is using gradle build tool. We are using jacoco plugin to generate test coverage report. Later we have added test suites using JVM Test Suite plugin of gradle. We have observed that all those test classes run by test suites are not getting covered in code coverage report of jacoco. So If anyone got some idea what exactly should i write in build.gradle file for accomplish this, that would be great. Thanks.

This is the build.gradle file snippet:-

plugins {
    id 'java'
    id 'jacoco'
    id 'jvm-test-suite'
}

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
}

testing {
    suites {
        test {
            useJUnitJupiter()
        }

        customTest(JvmTestSuite) {
            dependencies {
                ... // some dependencies
            }
        }
    }
}

tasks.named('check') {
    dependsOn(testing.suites.customTest)
}

dependencies {
... // some other dependencies
}

jacocoTestReport {
    dependsOn test
    reports {
        xml.required = true
    }
}


Solution 1:[1]

See the new JaCoCo Report Aggregation Plugin and the aggregation related Samples (under the Java heading) for information on how to consolidate coverage across multiple test suites.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tom Tresansky