Running jacocoReport

我只是一个虾纸丫 提交于 2019-12-09 02:26:45

问题


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 and I see in the log

:bl:jacocoTestReport (Thread[Daemon Thread 13,5,main] - start
:bl:jacocoTestReport
Skipping task ':bl:jacocoTestReport' as task onlyIf is false.
:bl:jacocoTestReport SKIPPED
:bl:jacocoTestReport (Thread[Daemon Thread 13,5,main]) - complete

What does it mean? Why report is not created?


回答1:


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




回答2:


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.




回答3:


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


来源:https://stackoverflow.com/questions/20032366/running-jacocoreport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!