GebReportingSpec: support for reporting from setupSpec/cleanupSpec

72 views
Skip to first unread message

Samuel Rossinovic

unread,
Feb 18, 2018, 6:05:49 PM2/18/18
to Geb User Mailing List
Hi.
Seems that calling GebReportingSpec.report() from the specification setup/teardown methods is unsupported ATM. Was wondering if there are any plans for supporting it?
Thanks!

Marcin Erdmann

unread,
Mar 6, 2018, 3:03:06 PM3/6/18
to Geb User Mailing List
Hi Samuel,

Can you please elaborate on why you believe it's not supported in setupSpec/cleanupSpec? Also, can you explain why you have a requirement for it?

Marcin

--
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+unsubscribe@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/bf64757b-e0a3-4e19-9fdc-9a3c869dfb54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samuel Rossinovic

unread,
Mar 7, 2018, 1:06:31 AM3/7/18
to Geb User Mailing List
Attempting to call report() from setupSpec() yields:
java.lang.NullPointerException: Cannot get property 'methodName' on null object


As to the use-case: I think reports are a very powerful feature. Indeed, the manual states that the reporting mechanism "can be used to snapshot the state of the browser at any point in time." I have specs that interact with the browser in setupSpec(), and reporting over those interactions is as-valuable in my view as reporting done in the actual features.

Example of interactions that I am inclined to push-into setupSpec when doing blaxbox testing is recreating any entities that are required by the spec, but are not directly part of the FUT. If setupSpec doesn't work correctly, it can fail the test, so reporting on setupSpec can be very helpful.

Thanks!



On Wednesday, March 7, 2018 at 7:03:06 AM UTC+11, Marcin Erdmann wrote:
Hi Samuel,

Can you please elaborate on why you believe it's not supported in setupSpec/cleanupSpec? Also, can you explain why you have a requirement for it?

Marcin
On Sun, Feb 18, 2018 at 11:05 PM, Samuel Rossinovic <samuel.r...@gmail.com> wrote:
Hi.
Seems that calling GebReportingSpec.report() from the specification setup/teardown methods is unsupported ATM. Was wondering if there are any plans for supporting it?
Thanks!

--
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.

Marcin Erdmann

unread,
Mar 7, 2018, 12:10:06 PM3/7/18
to Geb User Mailing List
Ok, I see what the problem is. You are using GebReportingSpec.report() which indeed is designed to only work from within feature methods and not fixture methods. This is because it uses the name of the test method when generating the report label (see https://github.com/geb/geb/blob/1eae07a36595094dc311ca98c063fb9484976413/module/geb-spock/src/main/groovy/geb/spock/GebReportingSpec.groovy#L63) and gebReportingSpecTestName on which you're getting the NPE is a JUnit rule which means that it is not initialized when setupSpec() is executed.

One workaround would be to directly use Browser.report() instead of GebReportingSpec.report() as you already are interacting with a browser instance in your fixture method. The only downside is that you'd have to put some effort into creating meaningful labels for your reports because you'd obviously loose the label decoration that GebReportingSpec.report() gives you.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

Samuel Rossinovic

unread,
Mar 7, 2018, 7:03:41 PM3/7/18
to Geb User Mailing List
Yep. I've actually attended to it already, and am producing reports with the full label, both from non-spec objects and in setupSpec(). I was more wondering in-general, whether there's a reason in-principal not to support such reporting through setup/teardown of the spec.

Marcin Erdmann

unread,
Mar 8, 2018, 3:56:26 AM3/8/18
to Geb User Mailing List
There's no reason in principal not to support it, it's just a limitation of the current implementation. Feel free to create an issue or provide a PR - the easiest solution would probably be to default the method name to something like "fixture" if gebReportingSpecTestName is null when calling GebReportingSpec.report().

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages