How to get Jacoco reports for the Karate test feature files using Gradle. (如何使用Gradle获取有关空手道测试功能文件的Jacoco报告。)
My project is a Gradle project and I am trying to integrate jacoco report feature in my project for the karate tests. (我的项目是Gradle项目,我正在尝试将jacoco报告功能集成到我的项目中以进行空手道测试。) The server is running in my local on 8080 port. (该服务器在我的本地8080端口上运行。)
I am doing the following way to generate jacoco report and please let me know is my approach correct and also give me a solution to get the jacoco report for the gradle project. (我正在按照以下方式生成jacoco报告,请让我知道我的方法是正确的,还给了我一个解决方案,以获取gradle项目的jacoco报告。)
1) First I am trying to generate jacoco execution data with the help of jacocoagent.jar as follows with a Gradle task: (1)首先,我尝试通过gradle任务在jacocoagent.jar的帮助下生成jacoco执行数据:)
java -javaagent:/pathtojacocojar/jacocoagent.jar=destfile=/pathtojocofile/jacoco.exec -jar my-app.jar
2) Next, I am running a Gradle task to generate the report (2)接下来,我正在运行Gradle任务以生成报告)
project.task ('jacocoAPIReport',type: org.gradle.testing.jacoco.tasks.JacocoReport) {
additionalSourceDirs = files(project.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(project.sourceSets.main.allSource.srcDirs)
classDirectories = files(project.sourceSets.main.output)
executionData = fileTree(dir: project.projectDir, includes: ["**/*.exec", "**/*.ec"])
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
onlyIf = {
true
}
doFirst {
executionData = files(executionData.findAll {
it.exists()
})
}
}
project.task('apiTest', type: Test) {
description = 'Runs the api tests'
group = 'verification'
testClassesDirs = project.sourceSets.apiTest.output.classesDirs
classpath =
project.sourceSets.apiTest.runtimeClasspath
useJUnitPlatform()
outputs.upToDateWhen { false }
finalizedBy jacocoAPIReport
}
I don't see any of my application's classes in the jococo.exec file. (在jococo.exec文件中没有看到我的应用程序的任何类。) I think, bcz of that I am always getting the coverage report as 0%. (我认为,我总是将覆盖率报告设为0%。)
ask by Hima Bindu translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…