我有三个测试源集
/src/tests/...
src/test-integration/
src/test-acceptance/
gradle build
仅运行单元测试,而我有单独的任务来运行测试集成和测试接受。 This setup ,基本上:
task acceptanceTest(type: Test) {
description = "Runs acceptance tests"
testReportDirName ="acceptance"
testClassesDir = sourceSets.acceptanceTest.output.classesDir
classpath += sourceSets.test.runtimeClasspath + sourceSets.acceptanceTest.runtimeClasspath
useJUnit()
testLogging {
events "passed", "skipped", "failed"
}
}
现在我唯一的问题是我希望验收/集成测试将其报告打印到“test”文件夹之外的其他位置,因为它们会相互覆盖。基本上我想更改 testReportDirName
属性,但仅限于任务。
最佳答案
您可以更改默认测试结果和报告目录,如下所示:
task acceptanceTest(type: Test) {
reports.html.destination = file("$reports.html.destination/acceptance")
reports.junitXml.destination = file("$reports.junitXml.destination/acceptance")
}
关于java - 在 gradle 中,如何为单独的任务创建单独的测试报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25860528/