4

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 Answers2

2

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

Harry Developer
  • 260
  • 1
  • 3
  • 15
-2

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

Leonard Brünings
  • 12,408
  • 1
  • 46
  • 66