【发布时间】:2019-10-28 01:10:52
【问题描述】:
我正在学习使用junit5。 我按照教程编写了一些动态测试,然后使用 gradle 运行它们。但是gradle默认输出的测试报告对我来说不够好,它不包含嵌套的测试容器结构。在运行动态测试时,是否有任何替代方法可以输出格式更好的测试报告?类似于intellijidea测试报告。 代码:
@TestFactory
Stream<DynamicNode> dynamicTestsWithContainers() {
return Stream.of("A", "B", "C")
.map({ input ->
dynamicContainer("Container " + input, Stream.of(
dynamicTest("not null", { -> assertNotNull(input) }) as DynamicNode,
dynamicContainer("properties", Stream.of(
dynamicTest("length > 0", { -> assertTrue(input.length() > 0) }),
dynamicTest("not empty", { -> assertFalse(input.isEmpty()) })
))
))
})
}
使用 gradle 运行:
使用 intellij idea 运行:
【问题讨论】: