PowerPoint Presentation
Testing Grails Applications with Selenium RC
Rob Fletcher, Energized Work
Comparison with webtest/g-func
Comparison with Selenium IDE
Test examples
Running tests
Browsers
Page Objects
Data Driving
Spock/BDD
Running Selenium RC Tests
grails install-plugin selenium-rc
grails test-app
grails test-app -functional
Show example suite run
Browsers
grails -Dselenium.browser=*firefox test-app
Selenium RC vs. Selenium IDE
Selenese not a 'real' language
Sequence, Selection & Iteration (1 out of 3)
No encapsulation / modularity
Better Factored Tests
Selenese tests as a 'run-on sentence'
divide into methods
simpler modularity (no custom commands)
leads into less repetition page object pattern
Bits of coverage hide in long tests
Temptation to extend tests
Writing Selenium RC Tests
Use @Mixin(SeleniumTest)
Simple
Works with non-JUnit frameworks
Extend GrailsSeleniumTestCase
Offers Selenese-like assertions, e.g. assertTextPresent
Easy migration from Selenese
Use Page Object Pattern
Tests do not interactdirectlywith Selenium
The Page Object Pattern
What is a page object?
exposes methods that reflect the things the user can see and do on a page
eliminate duplication by building abstractions
hides the detail of how
code completion
tests responsible for assertions, not page object
Underlying implementation can be changed
Page Object Test Example
Note does not extend or mixin Selenium test classes
shows how page object hide detail of implementation
Page object handles position of elements in table, test can access by name
Factory method that opens URL
Navigation method that returns another page object
Scrapes error messages and returns in useful form
Returns element value if present (can't do in Selenese)
Uses MOP to override property access to type in form fields
Data Driving
using monolithic data setup
Build test data
Fixtures
tearDown
Using Build-Test-Data
withTransaction blocks ensure data committed and errors thrown right away
Importance of tearDown
BDD Frameworks
Selenium RC &Spock
rfletcherEW
adhockery.blogspot.com
energizedwork.comgithub.com/robfletcher/grails-selenium-rc
Top Related