Running jacocoReport

后端 未结 3 1321
慢半拍i
慢半拍i 2021-01-07 16:38

I\'m using Gradle 1.7 and Jacoco plugin. My project uses Java and Scala plugins.
When I run gradlew -i clean jacocoTestReport

Report is not created

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 17:04

    None of the above worked for me. What worked for me was the following

    Add to the top of my build.gradle:

    apply plugin: 'jacoco' // code coverage reports
    

    Add the following as a 'task':

    // Generate code coverage reports ... run with jacoco
    jacocoTestReport{
        additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
        reports {
            xml.enabled false
            csv.enabled false
            html.destination "${buildDir}/reports/jacoco/html"
        }
        executionData = files('build/jacoco/test.exec')
    }
    

    Add the following to your gradle test task:

    finalizedBy jacocoTestReport
    

    Then I issued the following command:

    gradle run test jacoco
    

提交回复
热议问题