Create report on exception

13 views
Skip to first unread message

Ben Frey

unread,
Nov 5, 2020, 9:12:26 AM11/5/20
to Geb User Mailing List
I know by default Geb creates a report if the test reached the end but failed. Is there a way to create a report if an exception was thrown during the test? That's the case of most of my test failures and that feature would greatly help in diagnosing the failures.

Marcin Erdmann

unread,
Nov 8, 2020, 4:40:15 PM11/8/20
to geb-...@googlegroups.com
Hi Ben,

I know by default Geb creates a report if the test reached the end but failed.

I don't think that this is entirely true. The time of when the report is being taken upon a test failure is test framework (as in Spock, JUnit, TestNG) integration dependent but I believe that the report is taken as soon as the hook used by the integration reports a failure. For some of the integrations it might actually happen after cleanup code is executed. Can you please describe in detail which test framework you are using, what behaviour with regards to reporting on failureyou are observing and what behaviour you are expecting?
 
Is there a way to create a report if an exception was thrown during the test?

That will depend on the test framework we are talking about exposing a hook which is called as soon as an exception is being thrown from within a test. If there is a better mechanism for detecting the exception being thrown or test failure occurring than what we are currently using for the framework in question then I'd be more than happy to switch the integration to that hook.

Marcin

Ben Frey

unread,
Nov 8, 2020, 6:09:04 PM11/8/20
to geb-...@googlegroups.com
Oh, I didn't realize that the test framework would have such an impact. I'm using Spock in this case.

Ben

--
You received this message because you are subscribed to a topic in the Google Groups "Geb User Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geb-user/sQjkMRaBqdA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geb-user+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/CA%2B52dQQ6E0J2ezq-ET%3D%3DSYAvurd85VEOMJf50MfGaPokp3MjBQ%40mail.gmail.com.

Marcin Erdmann

unread,
Nov 9, 2020, 3:50:37 PM11/9/20
to geb-...@googlegroups.com
So I double checked and for the Spock integration, the failure report (the one taken with label "failure") is taken as soon as the exception happens and before any cleanup methods are called. The only cases where other code might be executed in-between the exception and the report being taken are:
- the failing feature method has a cleanup: block which will be executed before reporting
- an implementation of org.spockframework.runtime.IRunListener which has a non-empty implementation of error(ErrorInfo) method is registered with the spec before geb.spock.ReportingOnFailureExtension.visitSpec() which registers geb.spock.OnFailureReporter as a listener is executed

Basically, in most cases the failure report will be written as soon as the exception happens. Is this not what you are seeing, Ben?

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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/CAG7nOpiAa5fO_%2Bz8Q1RSCF11xMmNrQMKi71iWwDV%2BkNotQLG-g%40mail.gmail.com.

Ben Frey

unread,
Nov 10, 2020, 10:35:07 AM11/10/20
to Geb User Mailing List
Ahh, I see where my misunderstanding was - my spec was extending GebSpec rather than GebReportingSpec. With that change, I do get a report on any exception.
Reply all
Reply to author
Forward
0 new messages