Spock + GEB vs. Robot Framework [closed]
Asked Answered
M

1

12

Previously I used Robot Framework to automate testing of applications, but a new client asked pay attention to Spock + GEB. I've never used it, but I need to quickly compare two of these tools and make a choice. Please help me to understand how they differ and what are the strengths / weaknesses of each.

Mccreery answered 10/5, 2013 at 9:50 Comment(3)
Can you share what choice you made and whyOperate
The first choice was RF. It's simple to start and get quick result in making smoke tests of UI. It's extends with python's scripts so we are also able to successfully test loading xml files through web service and compare data in application with data in DB/file. Now we are going to switch to Geb+Spock. It's more difficult in understanding. It's not my decision, it's project direction to use Geb+Spock. I just started to work on it and this way looks not less promissing. Also I found a possibility to launch geb's scripts from LoadUI to make load testing, so, this can be a good plus.Mccreery
We've used both GEB and Robot for a few projects; and have continued using Robot on the more recent ones. One of the perks we've found is that our test team are comfortable writing Robot tests, and hence our tests are now written by both testers and developers (where as with GEB it was solely developers). For us, our testers are now using Robot for other projects (primarily testing webservices), so it's easy for them migrate between projects without having to learn a new tool for each. Writing Robot tests is simple and it's easy to have them run cross-browser which is nice too.Prittleprattle
F
14

I tell you about Geb, i use gebish for testing web-applications more 6 months. That's all his benefits:

  • Cross Browser Automation
  • jQuery-like API
  • Page Objects
  • Asynchronicity
  • Testing
  • Build System Integration

Now more details about each of them.

  • Cross Browser Automation

Geb leverages the WebDriver library for browser automation. This means that Geb works with any browser that WebDriver works with, and the list of browsers that WebDriver works with is growing all the time.

The core supported browsers are:

  • FireFox
  • Internet Explorer
  • Google Chrome
  • Opera

There is also experimental support for:

  • Chrome on Android
  • Safari on iPhone & iPad

WebDriver also supports remote drivers. This allows you to automate a browser running on another machine! This means you can easily run your test suite against an IE browser from the comfort of your Mac or Linux machine (and vice versa).

  • jQuery-like API

Geb takes inspiration from jQuery to provide a concise and effective way to get at content. This is called the Navigator API.

The dollar function can be used anywhere to select content based on CSS selectors, attribute matchers and/or indexes.

// CSS 3 selectors
$("div.some-class p:first[title='something']")

// Find via index and/or attribute matching
$("h1", 2, class: "heading")
$("p", name: "description")
$("ul.things li", 2)

// 'text' is special attribute for the element text content
$("h1", text: "All about Geb")

// Use builtin matchers and regular expressions
$("p", text: contains("Geb"))
$("input", value: ~/\d{3,}-\d{3,}-\d{3,}/)

// Chaining
$("div").find(".b")
$("div").filter(".c").parents()
$("p.c").siblings()
  • Page Objects

Geb has first class support for the Page Object pattern, leveraging Groovy's DSL capabilities to allow you the developer to easily define the interesting parts of your pages in a concise, maintanable and extensible manner.

import geb.Page

class LoginPage extends Page {
    static url = "http://myapp.com/login"
    static at = { heading.text() == "Please Login" }
    static content = {
        heading { $("h1") }
        loginForm { $("form.login") }
        loginButton(to: AdminPage) { loginForm.login() }
    }
}

class AdminPage extends Page {
    static at = { heading.text() == "Admin Section" }
    static content = {
        heading { $("h1") }
    }
}
  • Asynchronicity

Modern web pages are full of asynchronous operations like AJAX requests and animations. Geb provides built in support for this fact of life.

Any content lookup, or operation can be wrapped in a waitFor clause.

waitFor { 
    $("p.status").text() == "Asynchronous operation complete!"
}

This will keep testing the condition for a certain amount of time (which is configurable) until it passes. The same technique can be used to just wait for the content, not necessarily for the content to have some characteristic.

def dynamicParagraph = waitFor { $("p.dynamically-added") }
dynamicParagraph.text() == "Added dynamically!"

You can also define that content should be implicitly waited for in the Content DSL for page objects

import geb.Page

class DynamicPage extends Page {
    static content = {
        dynamicParagraph(wait: true) { $("p.dynamically-added") }
    }
}

With this definition, when dynamicParagraph is requested Geb will implictly wait for a certain amount of time for it to appear.

  • Testing

Geb provides integration modules for popular testing frameworks such as Spock, JUnit, TestNG, EasyB and Cucumber (via Cuke4Duke)

While Geb works great with all of these frameworks, it really shines with Spock. Spock is an innovative testing framework that is a great match for using with Geb. Using Spock + Geb gives you very clear, concise and easy to understand test specifications with very little effort.

import geb.Page
import geb.spock.GebSpec

class LoginSpec extends GebSpec {
    def "login to admin section"() {
        given:
        to LoginPage

        when:
        loginForm.with {
            username = "admin"
            password = "password"
        }

        and:
        loginButton.click()

        then:
        at AdminPage
    }
}
  • Build System Integration

Geb is easy to integrate into any build system, and information and examples on integrating with the following build/project systems is available:

  • Gradle
  • Grails
  • Maven

You can look my Example (Spock+GEB) here: github

Read more about geb here: Official Site

Thanks!!!

Farthing answered 10/5, 2013 at 21:50 Comment(4)
Thank you very much for such a complete and detailed response. But, unfortunately, I am a complete noob in all this and the following questions are still relevant for me: 1. How GEB interacts with Spock? I looked at the official sites, but haven't found information what I need to set to work with a Geb + Spock? How to getting started write a simpliest test on my PC. 2. As I understand all the tests are written in groovy and aimed at testing applications are written in the Java. But I do not understand what strong / weak side of this compared to the robot framework? Thank for your help.Mccreery
Answer: 1)For start you need install build automation on your PC(gradle, maven, grails) I use gradle, because - DSL language. After this go to geb home page and look how config build file(pom.xml - maven, build.gradle - gradle) hereFarthing
2) All tests write on groovy - 99% Java, in your tests you can check GUI(web-driver)+others check(check DB, check REST and others). I think it's strong side this framework.Farthing
And look my simple example.Farthing

© 2022 - 2024 — McMap. All rights reserved.