How to get log messages to display in Spock Reports?

2.4k Views Asked by At

I am using the Spock Reports extension in a Geb test. I am trying to find if there is any way to get the logging messages to display in the Spock report.

I have something roughly like this:

@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")

}

I'd like to see the the log stating the actual value to be output in my spock report, but I can't find a way. I've tried sending the log at info, warning, debug, error, and trace levels but no luck. Is this possible?

2

There are 2 best solutions below

0
On BEST ANSWER

If you happen to use Athaydes Spock Reports you can write messages to the report by using

reportInfo "This is a message"

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

This is possible since V1.4.0

2
On

Don't use @Slf4j just use println. spock, junit, and so on capture standard out and add it to the test results.