Running jacocoReport

后端 未结 3 1302
慢半拍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条回答
  • 2021-01-07 17:01

    The task will only run if coverage data is available. You can make sure of that by also running the test task.

    0 讨论(0)
  • 2021-01-07 17:04

    Add the following at a top level to your build.gradle:

    test {
     finalizedBy jacocoTestReport
    }
    

    This means that at the end of the test task the jacocoTestReport task should be run. You will receive your coverage analysis after run the tests.

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题