Skip to content

gw-kit/cover-jet-plugin

Repository files navigation

CoverJet Gradle plugin

Build codecov GitHub issues GitHub stars

CoverJet is lightweight Gradle plugin that uses IntelliJ Coverage engine to collect coverage data. Also, the plugin provides infrastructure to collect coverage from GradleRunner tests(See Gradle Runner tests).

Installation

Compatibility

CoverJet compatibility table:

CoverJet plugin Gradle min JVM
0.0.+ 7.6.4 - 8.13.+ 17

Apply plugin

Kotlin
plugins {
    id("io.github.gw-kit.cover-jet") version "<the-plugin-version>"
}

The latest release version is GitHub Release

Configuration

Kotlin
coverJet {
    // Default: 1.0.744
    intellijCoverageVersion.set("<agent-version>")
}

Execute

./gradlew test 

The test coverage data in binary format will be saved by the path build/coverage/<test-task-name>.ic.

Gradle Runner tests

This section is useful for plugin developers who want to collect coverage data from GradleRunner tests. Since, GradleRunner tests are executed in a separate JVM, the coverage data is not collected by default. CoverJet plugin generates all required JVM agent properties to collect coverage data.

The only action required from plugin dev is to configure the GradleRunner in the next way:

val projectRoot: File = File("<path-to-project>")
val gradleRunner = GradleRunner.create()
    .withPluginClasspath()
    .withProjectDir(projectRoot)
    // other configurations if needed
    .apply {
        // gradle testkit support
        val testKitPath: String = System.getProperty("io.github.gwkit.coverjet.test-kit")
        File(projectDir, "gradle.properties").appendText(
            File(testKitPath).readText()
        )
    }

Generate reports

Coming soon...