Reputation: 915
I have a web application running on wildfly 9 using gradle to build it, and I would like to get code coverage of manual tests, so I started using jacoco
for doing so. What I have so far is this in my build.gradle
file is this for starting java in debug mode:
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.debug = true
options.compilerArgs = ["-g"]
}
And this for defining jacoco reports
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
However, it does not generate jacoco folder, I think I am missing some point or something.
Upvotes: 1
Views: 2855
Reputation: 10574
Usage of JaCoCo involves following steps:
Information that you provide in the question - is about compilation of Java files and generation of report, but nothing about execution of JVM.
There are many ways to execute code with on-the-fly instrumentation depending on how JVM is started (Gradle/Maven/Ant plugins, etc.), but they all boil down to usage of JaCoCo Java Agent while starting JVM:
java -javaagent:jacocoagent.jar ...
Upvotes: 2
Reputation: 27996
By default, the jacocoTestReport
task is not wired into the DAG
for a normal build. To run it you can call the following from command line
./gradlew test jacocoTestReport
If you want it to run every time the tests run (which I don't recommend) then you can wire it onto the DAG
in your build.gradle
test.finalizedBy 'jacocoTestReport' // not perfect since it will run when test fails
Or perhaps
check.dependsOn 'jacocoTestReport' // 'build' task calls 'check' which calls 'test'
Upvotes: 0