Search code examples
grailsgroovyfunctional-testingspockgeb

How would you encapsulate the login action of a user so that you can reuse it for your tests when writing Geb/Spock tests for your Grails app?


I am beginning to write functional tests with Geb and Spock. I wrote a few simple ones for the login of my application but now, I would like to encapsulate the login process so I can test pages that require authentication.

How would you go about it?

Thanks in advance.

Also, I could not find a google group to post this question, where do people having Geb/Spock questions go to?


Solution

  • I found a great blog post that answered my question:

    Encapsulating page state and actions

    The author goes beyond my initial use case and also demonstrate how one would encapsulate and reuse test code around a pagination module for example.