All Projects → koral-- → jacoco-gradle-testkit-plugin

koral-- / jacoco-gradle-testkit-plugin

Licence: MIT license
Gradle plugin for JaCoCo code coverage in tests using Gradle TestKit

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to jacoco-gradle-testkit-plugin

kotlin-plugin-generated
A Kotlin compiler plugin that annotates Kotlin-generated methods for improved coverage reports
Stars: ✭ 33 (-10.81%)
Mutual labels:  coverage, gradle-plugin, jacoco
gradle-console-reporter
Gradle plugin to report various kinds of summaries to console.
Stars: ✭ 49 (+32.43%)
Mutual labels:  gradle-plugin, jacoco
Gradle Clover Plugin
Gradle plugin for generating a code coverage report using Clover
Stars: ✭ 67 (+81.08%)
Mutual labels:  coverage, gradle-plugin
travis-ci-tutorial-java
Just to learn how to use travis-ci in a java project!
Stars: ✭ 38 (+2.7%)
Mutual labels:  coverage, jacoco
jacoco-report
Github action that publishes the JaCoCo report as a comment in the Pull Request
Stars: ✭ 31 (-16.22%)
Mutual labels:  coverage, jacoco
tikione-jacocoverage
NetBeans module that provides JaCoCo code coverage for Ant based Java SE, Java EE and NetBeans Module projects (JDK5,6,7,8 compatible).
Stars: ✭ 25 (-32.43%)
Mutual labels:  coverage, jacoco
jacoco-badge-generator
Coverage badges, and pull request coverage checks, from JaCoCo reports in GitHub Actions
Stars: ✭ 53 (+43.24%)
Mutual labels:  coverage, jacoco
Jacoco
🔬 Java Code Coverage Library
Stars: ✭ 3,041 (+8118.92%)
Mutual labels:  coverage, jacoco
Gogradle
A Gradle Plugin Providing Full Support for Go
Stars: ✭ 712 (+1824.32%)
Mutual labels:  coverage, gradle-plugin
Gradle Pitest Plugin
Gradle plugin for PIT Mutation Testing
Stars: ✭ 144 (+289.19%)
Mutual labels:  coverage, gradle-plugin
Ehtrace
ATrace is a tool for tracing execution of binaries on Windows.
Stars: ✭ 218 (+489.19%)
Mutual labels:  coverage
Codecov Bash
Global coverage report uploader for Codecov
Stars: ✭ 220 (+494.59%)
Mutual labels:  coverage
AndroidLintReporter
Gradle Plugin to report Android Lint and Detekt result back to Github Pull Request
Stars: ✭ 22 (-40.54%)
Mutual labels:  gradle-plugin
gradle-natives
Gradle plugin to aid in managing native libraries associated with Java-based projects.
Stars: ✭ 32 (-13.51%)
Mutual labels:  gradle-plugin
Browser Extension
Codecov Browser Extension
Stars: ✭ 212 (+472.97%)
Mutual labels:  coverage
Express Mongoose Es6 Rest Api
💥 A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
Stars: ✭ 2,811 (+7497.3%)
Mutual labels:  coverage
Python Mocket
a socket mock framework - for all kinds of socket animals, web-clients included
Stars: ✭ 209 (+464.86%)
Mutual labels:  coverage
Cmake Scripts
A selection of useful scripts for use in CMake projects, include code coverage, sanitizers, and dependency graph generation.
Stars: ✭ 202 (+445.95%)
Mutual labels:  coverage
Bisect ppx
Code coverage for OCaml and ReScript
Stars: ✭ 204 (+451.35%)
Mutual labels:  coverage
codeartifact-gradle-plugin
Codeartifact gradle plugin
Stars: ✭ 14 (-62.16%)
Mutual labels:  gradle-plugin

AppVeyor codecov Bitrise

jacoco-gradle-testkit-plugin

Gradle plugin for JaCoCo code coverage in tests using Gradle TestKit.

Motivation

There is no built-it support for code coverage in TestKit. Those tests run in separate JVM and configuration of JaCoCo plugin is not taken into account. See Gradle forum post for more details.

Usage

  • Apply plugin in build.gradle:
plugins {
  id "pl.droidsonroids.jacoco.testkit" version "1.0.8"
}

This will add testkit-gradle.properties system resource.

  • Create gradle.properties file used by GradleRunner and populate it with content from mentioned resource. Sample kotlin code:
class AwesomeTest {

    fun InputStream.toFile(file: File) {
        use { input ->
            file.outputStream().use { input.copyTo(it) }
        }
    }

    fun GradleRunner.withJaCoCo(): GradleRunner {
        javaClass.classLoader.getResourceAsStream("testkit-gradle.properties").toFile(File(projectDir, "gradle.properties"))
        return this
    }

    @get:Rule
    val temporaryFolder = TemporaryProjectFolder()

    @Test
    fun `empty project builds successfuly`() {
        val result = GradleRunner.create()
                .withProjectDir(temporaryFolder.root)
                .withTestKitDir(temporaryFolder.newFolder())
                .withPluginClasspath()
                .withJaCoCo()
                .build()
    }
}

Adding coverage for another task (ex. integrationTest)

By default the plugin configures the test task for any project with Java plugin applied.

To configure the coverage for another task just add something like this:

jacocoTestKit {
    applyTo("intTestRuntimeOnly", tasks.named("integrationTest"))
}

Custom JaCoCo destination file

JaCoCo destination file path reads it from the JacocoTaskExtension so you can change it like this:

tasks.named("test").configure {
    jacoco {
        destinationFile = file('integration.exec')
    }
}

Update from 1.0.5 or older

Starting from plugin version 1.0.6 the minimum supported Gradle version is 4.9

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].