Gradle Jacoco and JUnit5

后端 未结 4 765
抹茶落季
抹茶落季 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 09:14

    Can be also resolved with direct agent injection:

    subprojects {
       apply plugin: 'jacoco'
    
       jacoco {
            toolVersion = "0.7.9"
       }
    
       configurations {
            testAgent {
                transitive = false
            }
       }
    
       dependencies {
            testAgent("org.jacoco:org.jacoco.agent:0.7.9:runtime")
       }
    
       tasks.withType(JavaExec) {
            if (it.name == 'junitPlatformTest') {
                doFirst {
                    jvmArgs "-javaagent:${configurations.testAgent.singleFile}=destfile=${project.buildDir.name}/jacoco/test.exec"
                }
            }
        }
    }
    

    then report will be available with jacocoTestReport task

提交回复
热议问题