• Save
Acceptance testing with Geb
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Acceptance testing with Geb

on

  • 8,638 views

Slides for a talk I present at SkillsMatter. ...

Slides for a talk I present at SkillsMatter.
http://skillsmatter.com/podcast/agile-testing/acceptance-testing-with-geb

This talk will cover the basics of using Geb http://geb.codehaus.org to automate browser testing.
It will compare Geb with raw WebDriver/Selenium showing Geb's expressive Groovy API.
It will also demonstrate how to integrate Geb with acceptance testing frameworks, namely Cucumber via Cuke4Duke.

We will also cover an experience report on how and why we transitioned from raw WebDriver to Geb and how existing WebDriver projects can be ported across to Geb with minimal initial effort due to its underlying use of WebDriver.

Statistics

Views

Total Views
8,638
Views on SlideShare
5,798
Embed Views
2,840

Actions

Likes
2
Downloads
0
Comments
1

10 Embeds 2,840

http://rapaul.com 1722
http://www.rapaul.com 1088
http://localhost 12
http://feeds.feedburner.com 7
http://local.syntel.com 3
http://www.docshut.com 2
http://prlog.ru 2
http://webcache.googleusercontent.com 2
http://translate.googleusercontent.com 1
http://newsblur.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • I want to learn GEB with Groovy. I need your contact info..
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Acceptance testing with Geb Presentation Transcript

  • 1. Acceptance Testing with Geb cucumber, cuke4duke, groovy, geb, webdriver, selenium, bdd, teamcityRichard Paul 2011-01-26
  • 2. Talk Overview Introduction to the testing technologies Experience report at F1000
  • 3. Testing Stack Maven Cucumber Geb WebDriver Browser
  • 4. Cuke4DukeAllow Cucumber to be run on the JVM via JRubyAll programming can be done in Java Groovy Scala ...Good fit for teams already fluent in JVM languages.
  • 5. Features - Wikipedia ExampleFeature: Search In order to learn more As an information seeker I want to find more information Scenario: Im feeling lucky Given I am on the Wikipedia homepage When I search for "dog" Then I am shown the "Dog" article
  • 6. Step Definitions - Wikipedia ExampleGiven(~I am on the Wikipedia homepage) { browser.go()}When(~I search for "(.+)") { query -> browser.find(#searchInput).value(query) browser.find(#searchButton).click()}Then(~I am shown the "(.+)" article) { article -> assert browser.find(h1).text() == article}
  • 7. Where does the browser come from?import geb.Browserthis.metaClass.mixin(cuke4duke.GroovyDsl)Before { browser = new Browser(http://wikipedia.org)}After { browser.driver.manage().deleteAllCookies()}
  • 8. Geb - Very Groovy BrowserAutomationhttp://geb.codehaus.org/Provides an expressive API for interacting with webbrowsers.Excellent documentation provided by the manual.
  • 9. Geb - Frequently used APIsgo(/search)$(#query).value(dog)$(#query).value() == dog$(#submit).click()Covers 90% of use cases
  • 10. Geb - Form Shortcutsdef form = $(#register)form.firstname = Richardform.lastname = Paulform.blog = http://rapaul.comform.submit()// Shortcut forform.find(input[name=firstname]).value(Richard)// Similarly can inspect withassert form.firstname == Richard
  • 11. Geb & WebDriverGeb uses WebDriver under the hood.Automatically chooses a driver based on classpath. HtmlUnit Firefox IE ChromeCan select a specific driver using geb.driver property.
  • 12. WebDriver to Geb MigrationStarting with WebDriver APIbrowser.findElementByCssSelector(.x)Change browser from WebDriver to Gebbrowser.driver.findElementByCssSelector(.x)Refactor when working in that areabrowser.find(.x)
  • 13. Groovys PowerAssertPowerAssert shows values for intermediary statementsassert $(.divTop20item strong)*.text() =~ English | | | [] [] ..regex..Can tell if the selector matched elements or if the textactual text didnt match without needing to rerun scenario.
  • 14. Geb & the Page Object PatternDefines a Content DSL for encapsulating reusable aspects of apage.Modules for page fragments.We use Cucumbers steps as the item of reuse so dont use thePage Object Pattern.http://geb.codehaus.org/manual/latest/pages.html#pageshttp://skillsmatter.com/podcast/groovy-grails/talk-by-tomas-lin
  • 15. Advantages of Geb (over WebDriver) Expressive API Caching of WebDriver between scenarios All the power of underlying WebDriver if needed
  • 16. Acceptance Testing @ F1000 2 week iterations, releasing every iteration Story wall with columns Sprint backlog, specify, dev/test, done Acceptance tests written with Cucumber Outside in development Acceptance tests drive view layer View layer drivers controller Controller drives service ... Acceptance & unit tests running in CI (TeamCity)
  • 17. TeamCity3 separate builds in TeamCity Key Features (tagged with @keyfeature) Non Key Features Work in Progress (tagged with @wip) Any WIP scenarios that pass fail the buildCucumber supports JUnit report format Instant notification on first failure Build statisticsMore detail at:http://www.rapaul.com/2010/12/17/cucumber-maven-teamcity/
  • 18. Lessons LearnedThe Why & What are so much harder than the How Identifying the value (In order to) is difficult Important to have all team members in planning session Declarative steps instead of imperative trails of clicked GUI itemsSmall slices Vertical slicing (pairing for knowledge gaps) As small as possible Initial search had no sorting, paging, filtering etc Feature Toggles YAGNI
  • 19. Lessons Learned (continued)Confidence in acceptance tests is critical 8 hours does not give confidence Flakey tests should be refactoredForgetting details for features near end of iteration Writing up full features & scenarios during planning is time consuming. Capture important details on back of card.Getting stakeholders to look at Cucumber reports is hard Marking up key features
  • 20. Tips for working with CucumberTag (@now) to just run the scenario you are working onFind unused steps with --format usage --dry-runCuke4Duke with Groovy uses a lot of memory Both heap and PermGen, RAM is cheap
  • 21. Discussion/Questions Thanks! http://rapaul.com @rapaul