Reporting for Spock: blocks

95 views
Skip to first unread message

battl...@gmx.de

unread,
Feb 29, 2016, 10:02:26 AM2/29/16
to Geb User Mailing List
Hi folks,

I am using the Spock integration of Geb. I know the GebReportingSpec which automatically takes an "end" report and properly sets the report group.
That is nice, but not much detail.
And inserting numerous report("my label") commands seems like code noise to me, as there already are labels in every Spock Specification.

Hence my question: Has anyone tried or does anyone have some hint for me, to execute report-commands for every specification block label?

So given a testcase like:

def "my testcase"() {
  given
: "initial state"
 
...

 
when: "data is entered"
 
...

 
then: "result is displayed"
 
...

}

how to dynamically "extend" it (using a custom base spec, or some trait etc) to effectively become:

def "my testcase"() {
  given
: "initial state"
 
...
  report
("GIVEN initial state")

 
when: "data is entered"
 
...
  report
("WHEN data is entered")

 
then: "result is displayed"
 
...
  report
("THEN result is displayed")
}

Yes, that would be a lot of files. But on some occasions that would be really helpful for us in order to communicate with business stakeholders.

Any advice on this topic would be very welcome!

Best regards,
Klaus Lutterjohann

eddy bongo

unread,
Feb 29, 2016, 10:04:46 AM2/29/16
to geb-...@googlegroups.com

Use renatoathaydes/spock-reports on github. I suspect that might be what you are after.

Cheers.

Eddy

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/f24d7a0c-fba5-4b3a-ae22-42f7291f9157%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

battl...@gmx.de

unread,
Feb 29, 2016, 11:02:34 AM2/29/16
to Geb User Mailing List
Thanks for your reply!
I have seen the spock-reports project before. Diving into it provides some insights already; however spock-reports only does "ex-post" summarizing.

My plan would involve hooking into the Spec and taking snapshots (applying Geb's ScreenshotReporter and PageSourceReporter) during the test run instead (like using the
report statement).

Any hint or idea for that?

C
heers,
Klaus

shorn....@gmail.com

unread,
Mar 20, 2016, 11:58:04 PM3/20/16
to Geb User Mailing List
Found this post while trying to do the same thing.

Motivation:
On a previous project we had a similar set-up taking multiple screenshots within an individual test (using QFTest to test Swing rather than Geb to test browser app, but same-same).
It was *incredibly* helpful to be able to compare all the screenshots, from the last successful test, with all the screenshots from the current failing test (often the root cause of a failing test would be much further back in the behaviour of the test than the last screen).


@Klaus
You might try taking screenshots whenever the page transitions using the PageChangeListener.pageWillChange() method (haven't implemented myself yet, but I'm assuming that will work).  That will probably come close to what you want.

I'm planning to take screenshots per page transition anyway, as our tests grow larger and we've started factoring out navigation logic/business entity creation logic into helper methods - we're going to want want screenshots of all those transitions within those helper functions, even though they're encapsulated inside a single "where" (or even "then") block.

Back to the question at hand though: it will definitely be useful to take a screenshot per "when" block - if it's worth splitting a feature test of a single page into multiple when/then blocks, it's likely worth taking a screenshot for each of those distinct usages.  Also, as an application gets more dynamic, it tends to do "page transitions" less.  This will make doing reports on page transition less useful - and make doing reports per when/then block more necessary.
Reply all
Reply to author
Forward
0 new messages