gpt4 book ai didi

gradle - 将Jacoco与Gradle一起使用

转载 作者:行者123 更新时间:2023-12-03 05:14:03 26 4
gpt4 key购买 nike

如果测试失败,Jacoco将无法生成代码覆盖率报告。

以下是我的gradle文件的相关部分:

task unitTest(type: Test) {
forkEvery = 1
jvmArgs = ['-Djava.net.preferIPv4Stack=true']
testClassesDir = sourceSets.unitTest.output.classesDir
classpath = sourceSets.unitTest.runtimeClasspath
exclude '**/**TestBase.*'
outputs.upToDateWhen { false }
ignoreFailures = true
finalizedBy jacocoTestReport
}

task functionalTest(type: Test) {
forkEvery = 1
jvmArgs = ['-Djava.net.preferIPv4Stack=true']
testClassesDir = sourceSets.functionalTest.output.classesDir
classpath = sourceSets.functionalTest.runtimeClasspath
exclude '**/**TestBase.*'
outputs.upToDateWhen { false }
}


jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."

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')
}

即使我指定了“ignoreFailures = true”,在测试运行后也没有代码覆盖率报告。
There were failing tests. See the report at: file:///unitTest/index.html
:MYModule:jacocoTestReport SKIPPED

BUILD SUCCESSFUL

Total time: 41 mins 34.018 secs

最佳答案

问题是executionData指向错误的“test.exec”。它应该是“unitTest.exec”,以正在执行的测试任务命名。

关于gradle - 将Jacoco与Gradle一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36271024/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com