Gradle Jacoco and JUnit5

后端 未结 4 759
抹茶落季
抹茶落季 2021-02-05 08:28

We just ported our unit tests to JUnit5. Realizing that this is still rather early adoption with little hints on google.

The most challenging was to get jacoco code cove

4条回答
  •  误落风尘
    2021-02-05 08:59

    Thank you, so the hack now looks like this:

    project.afterEvaluate {
        def junitPlatformTestTask = project.tasks.getByName('junitPlatformTest')
    
        // configure jacoco to analyze the junitPlatformTest task
        jacoco {
            // this tool version is compatible with
            toolVersion = "0.7.6.201602180812"
            applyTo junitPlatformTestTask
        }
    
        // create junit platform jacoco task
        project.task(type: JacocoReport, "junitPlatformJacocoReport",
                {
                    sourceDirectories = files("./src/main")
                    classDirectories = files("$buildDir/classes/main")
                    executionData junitPlatformTestTask
                })
    }
    

提交回复
热议问题