3

我在 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 报告中看到说明要输出的实际值的日志,但我找不到方法。我尝试在信息、警告、调试、错误和跟踪级别发送日志,但没有运气。这可能吗?

4

2 回答 2

2

如果您碰巧使用 Athaydes Spock 报告,您可以使用

reportInfo "This is a message"

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

从 V1.4.0 开始,这是可能的

于 2018-01-19T16:01:24.500 回答
-2

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

于 2017-08-29T21:57:39.497 回答