在GitLab中,将删除设置项目中的15.0测试覆盖率功能。
GitLab提供了在.gitlab-ci.yml中使用coverage关键字解析测试覆盖率。
所有要求均得到满足:
开头和结尾
为什么测试覆盖徽章仍然显示着unknown
test:
stage: test
script: gradle check
coverage: '/Total.*?([0-9]{1,3})%./'
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
artifacts:
when: always
reports:
junit: build/test-results/test/**/TEST-*.xml发布于 2022-05-26 15:29:38
为了让./gradlew test输出测试覆盖率摘要,我需要将gradle-jacoco-log添加到我的项目中。
plugins {
id 'org.barfuin.gradle.jacocolog' version '2.0.0'
}
test {
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
}这为我提供了以下控制台输出:
> Task :jacocoLogTestCoverage
Test Coverage:
- Class Coverage: 100%
- Method Coverage: 83.6%
- Branch Coverage: 75%
- Line Coverage: 85.5%
- Instruction Coverage: 83.1%
- Complexity Coverage: 82.5%然后,通过向Instruction Coverage添加以下内容,我可以选择向GitLab报告.gitlab-ci.yml
test:
stage: test
script: gradle check
coverage: '/ - Instruction Coverage: ([0-9.]+)%/'https://stackoverflow.com/questions/72381020
复制相似问题