使用 TestReport 聚合 gradle 多项目测试结果 [英] aggregating gradle multiproject test results using TestReport
本文介绍了使用 TestReport 聚合 gradle 多项目测试结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个如下所示的项目结构.我想使用 Gradle 中的 TestReport 功能来将所有测试结果聚合到一个目录中.然后我可以通过单个 index.html 文件访问所有子项目的所有测试结果.我怎样才能做到这一点?
<预><代码>.|--项目A|--src/test/...|--构建|--报告|--测试|--index.html(测试结果)|--..|--..|--项目B|--src/test/...|--构建|--报告|--测试|--index.html(测试结果)|--..|--.. 解决方案
来自 示例4. 为Gradle 用户指南中的子项目创建单元测试报告>:
子项目{应用插件:'java'//禁用单个测试任务的测试报告测试 {report.html.enabled = false}}任务测试报告(类型:TestReport){destinationDir = file("$buildDir/reports/allTests")//将 `test` 任务的结果包含在所有子项目中报告子项目*.test}
可以从 samples/testing/testReport
获得完整的 Gradle 发行版中的完整示例.
I have a project structure that looks like the below. I want to use the TestReport functionality in Gradle to aggregate all the test results to a single directory. Then I can access all the test results through a single index.html file for ALL subprojects. How can I accomplish this?
.
|--ProjectA
|--src/test/...
|--build
|--reports
|--tests
|--index.html (testresults)
|--..
|--..
|--ProjectB
|--src/test/...
|--build
|--reports
|--tests
|--index.html (testresults)
|--..
|--..
解决方案
From Example 4. Creating a unit test report for subprojects in the Gradle User Guide:
subprojects {
apply plugin: 'java'
// Disable the test report for the individual test task
test {
reports.html.enabled = false
}
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}
Fully working sample is available from samples/testing/testReport
in the full Gradle distribution.
这篇关于使用 TestReport 聚合 gradle 多项目测试结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文