Search code examples
spockgebspock-reports

How to get log messages to display in Spock Reports?


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?


Solution

  • 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