Get screenshots for failing tests

40 views
Skip to first unread message

Lee

unread,
Dec 18, 2019, 5:28:46 PM12/18/19
to Geb User Mailing List
I'm trying to enable the ability to take screenshots when our Geb tests fail in a Chrome browser.  Even though my tests fail, I am not seeing any reports and/or screenshots being generated.

I'm executing the tests via a Gradle task if that matters.

I'm using Geb 2.3 and Spock 1.1-groovy-2.4

I've added the following to my gebConfig.groovy file:
  • reportOnTestFailureOnly = false
  • reportsDir = "target/execution-reports"
That should be the only configurations that are needed, correct?

If so, are there any suggestions how I may be able to troubleshoot this?

I appreciate any assistance,

Lee

Alexander Kriegisch

unread,
Dec 18, 2019, 10:29:34 PM12/18/19
to geb-...@googlegroups.com
You did not provide any Geb tests, so I can just ask speculatively: Do
your Geb tests extend GebReportingSpec instead of just GebSpec? And did
you try to manually create at least one screenshot from a running test
(before failure) via

report "dummy screenshot"

--
Alexander Kriegisch
https://scrum-master.de
> --
> 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
> <mailto:geb-user+u...@googlegroups.com> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/8fa7f83e-179f-4c2f-8759-51f7c9e7b766%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/8fa7f83e-179f-4c2f-8759-51f7c9e7b766%40googlegroups.com?utm_medium=email&utm_source=footer>
> .


Lee

unread,
Dec 20, 2019, 10:01:34 AM12/20/19
to Geb User Mailing List
Thanks Alexander.

Not sure why, but the way you worded your response made the documentation I read click.  I'll need to experiment a little more now to see if I can get this working.  I'm working with some inherited code that I'll need to figure out how to work this in.

Also, if I'm understanding correctly, we'll need to ultimately update every test within which we would like screenshots, correct?  With a call to "report()"?  My initial understanding was that we could just update the gebConfig.groovy and it would apply to all tests globally without modify the individual tests themselves.  Sounds like I misunderstood, correct?

-Lee

Michael Kutz

unread,
Dec 20, 2019, 12:49:16 PM12/20/19
to Geb User Mailing List
You just need to make the extend GebReportingSpec instead of GebSpec. No need to call report() manually.

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/35957058-73e3-4484-8f21-9d3c54fd4ec6%40googlegroups.com.

Alexander Kriegisch

unread,
Dec 20, 2019, 9:27:50 PM12/20/19
to geb-...@googlegroups.com
In some more detail:

I asked you to call "report" just in order to test if screenshots work at all by *manually* creating a screenshot at any given point in your test (after opening the first page, of course). That is easier than to make your test fail and play around with the configuration at the same time. Once it is established that you can create a screenshot, you can adjust your GebConfig in order to specify under which circumstances you want to have automatic screenshots at the end of each test.

But as Michael and I implicitly said already: In order for any Geb test to be able to use the screenshot feature - in Geb nomenclature this is called "reporting" - the Geb specification *has to* extend GebReportingSpec or another test base class extending GebReportingSpec.

Please read the Book of Geb, e.g.

https://gebish.org/manual/current/#testing-reporting
https://gebish.org/manual/current/#reporting

--
Alexander Kriegisch
https://scrum-master.de


Michael Kutz schrieb am 21.12.2019 00:49 (GMT +07:00):
>
> You just need to make the extend GebReportingSpec instead of GebSpec. No
> need to call report() manually.
>
>
> Lee <lee.l...@gmail.com <mailto:lee.l...@gmail.com> >
>> <mailto:geb-user+u...@googlegroups.com> .
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/geb-user/35957058-73e3-4484-8f21-9d3c54fd4ec6%40googlegroups.com
>> <https://groups.google.com/d/msgid/geb-user/35957058-73e3-4484-8f21-9d3c54fd4ec6%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>
> --
> 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
> <mailto:geb-user+u...@googlegroups.com> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/CALYktxPa93NKJC6zRNwA3jyVKnydM9DcpTEtwfxdmN7RFMSXeg%40mail.gmail.com
> <https://groups.google.com/d/msgid/geb-user/CALYktxPa93NKJC6zRNwA3jyVKnydM9DcpTEtwfxdmN7RFMSXeg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .


Lee

unread,
Dec 23, 2019, 12:51:42 PM12/23/19
to Geb User Mailing List
Alexander and Micha,

I was able to get screenshots working by pulling down https://github.com/geb/geb-example-gradle and configuring it per your recommendations.

The project I'm currently working with was setup in such a way that it that it will take some refactoring to be able to get a base class to extend GebReportingSpec properly.  One would think this should be easy, but trust me, it won't be.  ;-)

Thank you again for your help with this.  It is very appreciated.

Lee


On Friday, December 20, 2019 at 8:27:50 PM UTC-6, Alexander Kriegisch wrote:
In some more detail:

I asked you to call "report" just in order to test if screenshots work at all by *manually* creating a screenshot at any given point in your test (after opening the first page, of course). That is easier than to make your test fail and play around with the configuration at the same time. Once it is established that you can create a screenshot, you can adjust your GebConfig in order to specify under which circumstances you want to have automatic screenshots at the end of each test.

But as Michael and I implicitly said already: In order for any Geb test to be able to use the screenshot feature - in Geb nomenclature this is called "reporting" - the Geb specification *has to* extend GebReportingSpec or another test base class extending GebReportingSpec.

Please read the Book of Geb, e.g.

https://gebish.org/manual/current/#testing-reporting
https://gebish.org/manual/current/#reporting

--
Alexander Kriegisch
https://scrum-master.de


Michael Kutz schrieb am 21.12.2019 00:49 (GMT +07:00):
>
> You just need to make the extend GebReportingSpec instead of GebSpec. No
> need to call report() manually.
>
>
>> https://groups.google.com/d/msgid/geb-user/35957058-73e3-4484-8f21-9d3c54fd4ec6%40googlegroups.com
>> <https://groups.google.com/d/msgid/geb-user/35957058-73e3-4484-8f21-9d3c54fd4ec6%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>
> --
> 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-...@googlegroups.com
> <mailto:geb-...@googlegroups.com> .
> To view this discussion on the web visit

Michael Kutz

unread,
Dec 23, 2019, 12:52:53 PM12/23/19
to Geb User Mailing List
Glad it helped 🙂

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/4b52e52a-f1fc-47d1-b0c4-2638e328a114%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages