webtest - efficient functional web testing with htmlunit and beyond
TRANSCRIPT
WebTest
Efficient Functional Web Testing
with HtmlUnit and Beyond
Marc Guillemot
JUG Cologne
25.08.2008
Your speaker
French developer exiled in Germany
Independent consultant since 2002
Focus on Java, Groovy, Grails and ... web testing
HtmlUnit & WebTest lead developer
Committer to Groovy & NekoHTML
Blog: http://mguillem.wordpress.com
Site (coming): http://www.efficient-webtesting.com
Agenda
Introduction to WebTest
Test automation: a software engineering activity
Extending WebTest
Myths and best practices
WebTest and AJAX
WebTest's future(s)
Conclusion
Q & A
What I won't say
Why you should automate your web application tests
How to install WebTest
How to integrate into your build
Why Selenium sucks ;-)
What is WebTest
Automated web functional testing tool
Open Source (Apache 2 license)
Founded in 2001
Currently 4 committers (Germany, Switzerland, USA, Australia)
Built on top of Apache Ant
http://webtest.canoo.com
Who uses WebTest?
Open Source project => no idea!
Let's look at the mailing list: 700 subscribers
*@apache.org
*@*.gov
Akamai, AMD, Axa, Bayer, Boeing, BT, Citigroup, Crdit-Suisse, CSC, DHL, EDS, IBM, Lexmark, Novartis, Oracle, Paypal, Sun, T-Mobile, Thalesgroup, Verisign, Zuehlke, ...
=> everybody from small to huge
demo(on a strange site)
Over 100 WebTest Steps
General
...
Forms
...
Verification
...
...
Excel documents
...
Email, Applets, ...
Comprehensive online documentation
http://webtest.canoo.com
A software engineering activity
Apply rules of software engineering
Remove duplications
Extract modules
Use source control
Consider modifications and extensions
Ant, Java, Groovy
XPath
Learn XPath
Learn XPath!!!
Apply it wisely
/html/body/div[2]/center/table[3]/tr/td[@id='total']
//*[@id='total']
Write HTML code allowing simple XPath expressions!!!
Apply the right testing paradigm
Capture / replay
Model based testing
Data driven testing
Scripted automation
demoWebTestRecorder
Model based testing
Specification: modelling expected behavior
Be tolerant to accidental behavior
Example:
bad XPath: /html/body/div[2]/center/table[3]
better: //*[@id='total']
Fault model: modelling unexpected behavior
demodata driven
Scripted automation
Maximum flexibility and power
Maximum responsibility
Extending
WebTest
Why?
Go beyond built-in features
Customize for special needs
Make your tests easier to write
Make your tests results easier to read
Building blocks
WebTest
GroovyApache ANT
Apache POI...HtmlUnitJakarta commons-httpclientNekoHTMLMozilla Rhino
...
WebTest uses HtmlUnit
A browser for Java programms
100% pure java, headless
Able to simulate FF or IE
Very fast and leightweight
Used in WebTest but as well in JSFUnit, WebDriver, JWebUnit, Cactus, Celerity, Schnell, ...
Very good JS support... but not yet perfect
Go beyond built-in features
...
step.context.webClient.credentialsProvider.addNTLMProxyCredentials(
"michael", "secret",
"testserver", 12345,
"BlueGene", "my.windows.domain")
.....
...
Hack the web connection
Define custom steps
Works but:
too low level
not reusable
...
...
Define custom steps