Eclipse - Java - Gradle 正在跳过 jacocoTestReport
Eclipse - Java - Gradle is skipping jacocoTestReport
项目结构:
src/main/java
src/main/resources
src/test/java
Gradle 版本:2.2.1
这是我的 build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
version = '1.0'
sourceCompatibility = 1.7
targetCompatibility = 1.7
test {
include 'src/test/java'
finalizedBy jacocoTestReport
}
jacoco {
toolVersion = "0.7.6.201602180812"
}
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"
}
}
当我 运行 gradle 任务 "test jacocoTestReport" 时,我得到以下结果
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:jacocoTestReport SKIPPED
有人可以建议应该添加什么来执行 jacoco 测试报告。
谢谢。
我能够通过以下设置生成代码覆盖率结果。
apply plugin: 'jacoco'
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
只有在覆盖率数据可用时,任务才会 运行。您还可以通过 运行 执行 test
任务来确保这一点。
来源 - Running jacocoReport
派对迟到了,但 none 上面的答案为我解决了。相反,改变
dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0-M2'
}
至
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}
工作起来很有魅力 ()。
您可以通过以下方式强制它 运行:
jacocoTestReport {
onlyIf = {
true
}
}
这可能会给出一个错误(首先它没有 运行 是有原因的),但错误应该提供更多信息。
不幸的是,none 这些答案对我有用。
对于 Spring 2.5 用户,他们坚持了几个小时 -就像我自己.
我遇到了类似的问题。
我没有生成 exec 文件。
正因为如此,
我发现 jacocoTestReport 只是“skipped”。
我通过添加修复了它:
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
那是因为我正在使用 Junit5 和 spring 启动 2.X - Gradle 7.1
截至今天,测试任务中默认不会调用 Junit5。
项目结构:
src/main/java
src/main/resources
src/test/java
Gradle 版本:2.2.1
这是我的 build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
version = '1.0'
sourceCompatibility = 1.7
targetCompatibility = 1.7
test {
include 'src/test/java'
finalizedBy jacocoTestReport
}
jacoco {
toolVersion = "0.7.6.201602180812"
}
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"
}
}
当我 运行 gradle 任务 "test jacocoTestReport" 时,我得到以下结果
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:jacocoTestReport SKIPPED
有人可以建议应该添加什么来执行 jacoco 测试报告。
谢谢。
我能够通过以下设置生成代码覆盖率结果。
apply plugin: 'jacoco'
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
只有在覆盖率数据可用时,任务才会 运行。您还可以通过 运行 执行 test
任务来确保这一点。
来源 - Running jacocoReport
派对迟到了,但 none 上面的答案为我解决了。相反,改变
dependencies {
testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0-M2'
}
至
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}
工作起来很有魅力 (
您可以通过以下方式强制它 运行:
jacocoTestReport { onlyIf = { true } }
这可能会给出一个错误(首先它没有 运行 是有原因的),但错误应该提供更多信息。
不幸的是,none 这些答案对我有用。
对于 Spring 2.5 用户,他们坚持了几个小时 -就像我自己.
我遇到了类似的问题。
我没有生成 exec 文件。
正因为如此,
我发现 jacocoTestReport 只是“skipped”。
我通过添加修复了它:
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
那是因为我正在使用 Junit5 和 spring 启动 2.X - Gradle 7.1
截至今天,测试任务中默认不会调用 Junit5。