【发布时间】:2021-12-29 19:56:39
【问题描述】:
我正在尝试从我的 junit 测试中输出 BDD,如下所示:-
Feature: Adv Name Search
Scenario: Search by name v1
Given I am at the homepage
When I search for name Brad Pitt
And I click the search button2
Then I expect to see results with name 'Brad Pitt'
在 IntelliJ IDE 中运行时,这显示得很好,但在 Gradle 中运行时,什么都没有显示。我做了一些研究并启用了测试showStandardStreams boolean 即
在我的build.gradle 文件中我添加了...
test {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
}
这会产生...
> Task :test
Adv Name Search STANDARD_OUT
Feature: Adv Name Search
Tests the advanced name search feature in IMDB
Adv Name Search > Search by name v1 STANDARD_OUT
Scenario: Search by name v1
Given I am at the homepage
When I search for name Brad Pitt
And I click the search button2
Then I expect to see results with name 'Brad Pitt'
... 这非常接近,但我真的不想看到 gradle 的输出(带有 STANDARD_OUT 的行 + 额外的空白行)。
Adv Name Search STANDARD_OUT
有没有办法不在 test 部分显示额外的 Gradle 日志记录?
或者也许我的测试根本不应该使用System.out.println,而是使用正确的日志记录(例如log4j)+ gradle config来显示这些?
感谢任何帮助/建议。
更新(1)
如果有人想快速克隆和./gradlew clean test,我在https://github.com/bobmarks/stackoverflow-junit5-gradle 创建了一个最小可重现示例。
【问题讨论】: