如何在Spock Reports中显示日志消息?

时间:2017-08-29 20:05:39

标签: spock geb spock-reports

我在Geb测试中使用Spock Reports扩展。我试图找到是否有任何方法可以在Spock报告中显示日志消息。

我有类似的东西:

@Slf4j
class SpockReportExample extends GebReportingSpec {

    def expectedVar = "5"

    when: "I click the button."
    button.click()

    then: "The new value is displayed."
    def value = formElement.value()
    value==expectedValue
    log.info("The new value is $value")

}

我想查看日志,说明我的spock报告中要输出的实际值,但我找不到方法。我已尝试在信息,警告,调试,错误和跟踪级别发送日志,但没有运气。这可能吗?

2 个答案:

答案 0 :(得分:1)

如果您碰巧使用Athaydes Spock Reports,则可以使用

将消息写入报告
reportInfo "This is a message"

请参阅https://github.com/renatoathaydes/spock-reports#how-to-use-it

自V1.4.0以来这是可能的

答案 1 :(得分:-2)

不要使用@Slf4j只使用println。 spock,junit等捕获标准输出并将其添加到测试结果中。