4 Replies Latest reply: Jun 4, 2012 1:28 PM by Dan Allen RSS

An intro to functional testing, page objects and Geb

Dan Allen Master

I recently read an article on Groovy Functional Testing with Geb, published on jaxenter.com. It provides a really nice introduction to functional testing and page objects. It also gets you thinking about the advantages of using Groovy rather than Java for browser automation. This integration is certainly worth considering for Arquillian Drone (see ARQ-977). Especially since the article claims that "Geb is the most elegant and powerful browser automation tool available today." If that's so, we want that power in Arquillian

 

Here are a few of the topics covered in this article that I think are relevant for this group:

 

  • A definition of functional testing
  • The state of functional testing today
  • An in-depth introduction to the page object pattern
  • Introduction to Geb and Groovy for (web-based) functional testing

 

The article defines functional testing as:

Unlike unit testing, functional testing ignores the specifics of the underlying software component under test. A functional test merely asserts that providing certain input results in certain output. In the context of a web application, this usually means programmatically controlling a web browser to simulate the actions of a user on a web page.

 

We also see in this article a line that we use often when presenting the value of the Arquillian platform:

...traditional unit testing only goes so far. Some of the most serious bugs in a web application tend to be things a unit test has no way to check for

 

Of course, there is no silver bullet for testing. Testing is multi-faceted. Unit tests just happen to be simpler to write and comprehend. We focus a lot on more complex testing because traditionally it's been very hard.

 

The article identifies page objects as one of the key ways to make web-based testing simpler:

 

Page Objects [reduce] test fragility by letting you reason about your web pages and components as though they were part of an object hierarchy. If the structure of a page changes, you need only update a selector in one place within your Page class—often, no changes to the test code itself are required.

 

In other words, page objects adhere to the DRY principle.

 

Even if you aren't interested in writing tests in Geb / Groovy, the article is worth reading for its in-depth introduction to page objects. Check it out and let's discuss.

  • 1. Re: An intro to functional testing, page objects and Geb
    Lukáš Fryč Master

    Hi Dan,

     

    I'm very impressed by Geb, it basically shares many goals with Graphene 2

    (expect that Graphene is designed to be Javaish).

     

    I really like the Modules feature, which we want to introduce into Graphene 2 (called Component Objects)

    http://www.gebish.org/manual/current/modules.html#modules

     

    This allow you to encapsulate all the framework components and bundle Component Objects as the reusable test base for your framework like RichFaces, decreasing development and maintanance costs for functional tests!

     

    ----

     

    Let me just summarize what Graphene 2 intends to add over Geb:

     

    • request guards (HTTP / XHR)
    • WebDriver command interceptors
    • Page extensions (JavaScript injection)
    • Java-to-JavaScript calling interfaces
      • including QUnit adapter for calling QUnit tests from functional tests

     

    I think it make very sense to prototype integration of Geb with Drone and then try to migrate prototyped Graphene's features there.

     

    ----

     

    My only concern is about Groovy's eco-system of tooling:

     

    • test runners for all major IDEs
    • Maven integration
    • integration with Arquillian / Warp, etc.

     

    That's something we need to investigate.

  • 2. Re: An intro to functional testing, page objects and Geb
    Bartosz Majsak Master

    Hi guys,

     

    I spoke with Luke on 33degree in Krakow. He was interested in Arquillian and told me that he would love to make arquillian integration a first class geb module and maintain it within the Geb project

     

    I think it's high time to try involve him a bit and share experience and ideas. And go beyond simple integration.

     

    Cheers,

    Bartosz

  • 3. Re: An intro to functional testing, page objects and Geb
    Lukáš Fryč Master

    Bartosz Majsak wrote:

     

    I think it's high time to try involve him a bit and share experience and ideas. And go beyond simple integration.

    Go for it!

  • 4. Re: An intro to functional testing, page objects and Geb
    Dan Allen Master

    Lukáš Fryč wrote:

     

    Bartosz Majsak wrote:

     

    I think it's high time to try involve him a bit and share experience and ideas. And go beyond simple integration.

    Go for it!

     

    Absolutely!

     

    That way improvements in Graphene and Geb can flow both ways. It sounds like both are going to be valuable to each audience (Java and Groovy). And of course, we want to be able to mix Geb with Warp, so we'll want to make sure Luke understands the benefits of the WebDriver command interceptors.