Spock + GEB vs. Robot Framework -


previously used robot framework automate testing of applications, new client asked pay attention spock + geb. i've never used it, need compare 2 of these tools , make choice. please me understand how differ , strengths / weaknesses of each.

i tell geb, use gebish testing web-applications more 6 months. that's benefits:

  • cross browser automation
  • jquery-like api
  • page objects
  • asynchronicity
  • testing
  • build system integration

now more details each of them.

  • cross browser automation

geb leverages webdriver library browser automation. means geb works browser webdriver works with, , list of browsers webdriver works growing time.

the core supported browsers are:

  • firefox
  • internet explorer
  • google chrome
  • opera

there experimental support for:

  • chrome on android
  • safari on iphone & ipad

webdriver supports remote drivers. allows automate browser running on machine! means can run test suite against ie browser comfort of mac or linux machine (and vice versa).

  • jquery-like api

geb takes inspiration jquery provide concise , effective way @ content. called navigator api.

the dollar function can used anywhere 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' special attribute element text content $("h1", text: "all geb")  // use builtin matchers , 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 page object pattern, leveraging groovy's dsl capabilities allow developer define interesting parts of pages in concise, maintanable , extensible manner.

import geb.page  class loginpage extends page {     static url = "http://myapp.com/login"     static @ = { heading.text() == "please login" }     static content = {         heading { $("h1") }         loginform { $("form.login") }         loginbutton(to: adminpage) { loginform.login() }     } }  class adminpage extends page {     static @ = { heading.text() == "admin section" }     static content = {         heading { $("h1") }     } } 
  • asynchronicity

modern web pages full of asynchronous operations ajax requests , animations. geb provides built in support fact of life.

any content lookup, or operation can wrapped in waitfor clause.

waitfor {      $("p.status").text() == "asynchronous operation complete!" } 

this keep testing condition amount of time (which configurable) until passes. same technique can used wait content, not content have characteristic.

def dynamicparagraph = waitfor { $("p.dynamically-added") } dynamicparagraph.text() == "added dynamically!" 

you can define content should implicitly waited in content dsl page objects

import geb.page  class dynamicpage extends page {     static content = {         dynamicparagraph(wait: true) { $("p.dynamically-added") }     } } 

with definition, when dynamicparagraph requested geb implictly wait amount of time appear.

  • testing

geb provides integration modules popular testing frameworks such spock, junit, testng, easyb , cucumber (via cuke4duke)

while geb works great of these frameworks, shines spock. spock innovative testing framework great match using geb. using spock + geb gives clear, concise , easy understand test specifications little effort.

import geb.page import geb.spock.gebspec  class loginspec extends gebspec {     def "login admin section"() {         given:         loginpage          when:         loginform.with {             username = "admin"             password = "password"         }          and:         loginbutton.click()          then:         @ adminpage     } } 
  • build system integration

geb easy integrate build system, , information , examples on integrating following build/project systems available:

  • gradle
  • grails
  • maven

you can example (spock+geb) here: github

read more geb here: official site

thanks!!!


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -