java - 在 gradle 中,如何为单独的任务创建单独的测试报告?

标签 java junit gradle continuous-integration acceptance-testing

我有三个测试源集

/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/

相关文章:

java - 使用 @PostConstruct 模拟类会导致初始化失败

gradle - 如何使用Kotlin Gradle DSL在 block 内获取自定义方法?

安卓。 Gradle 构建错误 : Error parsing XML: not well-formed (invalid token)

java - FitNesse 与 JUnit : Execute suites in parallel

java - 从 Actor 运行 CompletableFuture

java - 调用fragment中的方法

java - 如何使用 Spring Data 将文档插入到 mongodb 中的特定集合?

java - 如何从 JUnit assertEquals() 方法获取输出并将其放入变量?

postgresql - Moqui 1.4.1 Postgresql配置

java - ArrayList<CustomObject> 无法添加对象