Geb reports state after cleanup, not before

37 views
Skip to first unread message

Paul Wellner Bou

unread,
Aug 5, 2016, 5:34:24 AM8/5/16
to Geb User Mailing List
Hi,

I have a failing webtest in this structure:

    def "test"() {
        when:
        to LoginPage

        and:
        login("...", "...")

        then:
        at LoggedInPage

        and:
        waitFor {
            assertHasAccess()
        }

        cleanup:
        logout()
    }

Unfortunately the reports (HTML and Screenshot) are taken from the state after the logout, after the cleanup task, I would expect it to be reported before.
Can I change this behaviour? Or am I doing something wrong when cleaning up?

I am using:

        groovyVersion = '2.4.5'
        gebVersion = '0.13.1'
        seleniumVersion = '2.51.0'

Thanks and best regards
Paul.

Marcin Erdmann

unread,
Aug 8, 2016, 4:36:36 PM8/8/16
to Geb User Mailing List
Hi Paul,

The behaviour you are describing is as expected. This is because report triggering is implemented in a cleanup method of GebReportingSpec which is, I assume, a super class of your spec and cleanup methods are called by Spock in the reverse order of inheritance.

If you wish to generate a report as soon as an error happens then I would suggest not using GebReportingSpec but writing a global Spock extension which installs an IRunListener onto each SpecInfo and implement the report generation triggering in IRunListener#error(ErrorInfo) - see this stackoverflow response for more details on how to implement an extension (http://stackoverflow.com/questions/16420034/execute-some-action-when-spock-test-fails/16421436#16421436) and sources of GebReportingSpec for how the report triggering is implemented.

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/d6ec7fc3-f606-4a14-8cfd-9f3201ed062e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages