• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Why Your Selenium Tests are so Dang Brittle, and What to Do About It
 

Why Your Selenium Tests are so Dang Brittle, and What to Do About It

on

  • 4,039 views

If you are writing automated through-the-GUI tests for a web application, you are in danger of creating tests that are more expensive to maintain than they are worth. With well-factored Selenium RC ...

If you are writing automated through-the-GUI tests for a web application, you are in danger of creating tests that are more expensive to maintain than they are worth. With well-factored Selenium RC tests running in Junit or TestNG, you can keep your abstraction layers or "Lingos" -- small bounded bits of slang for discrete parts of the object model -- separate, thereby reducing the maintenance costs of your tests, and improving your sanity.

This presentation is from a technical track webinar on:

•How and why automated web app code gets so dang brittle
•Why the expressiveness, readability, and fluency of your test code is so important to its maintenance cost
•Some basic, useful OOD patterns for writing very expressive web app tests using Selenium RC, in Java and in C#/.NET
•Some useful OOD principles to guide your design decisions, like keeping modules small, the SRP, DRY, "Lingos", and "Lingual Design"
•Some OOD principles worth violating, frequently, when writing automated test code, because it's just very different from application code
•How and why to prefer element locators like Id and Value attributes to xPath; how to keep xPath least brittle
•An introduction to Domain Specific Languages (DSLs) built on top of Selenium RC, using FitNesse
•An introduction to "fluent" Selenium RC testing using Scala
Prerequisites include experience with Java or C#, and ideally some basic OOD familiarity (inheritance, composition, encapsulation, polymorphism).

To view or download a replay of the event (WMV format), which included live demonstrations, please visit: http://www.pillartechnology.com/content/webinardetail/id/16

Statistics

Views

Total Views
4,039
Views on SlideShare
3,947
Embed Views
92

Actions

Likes
1
Downloads
49
Comments
0

1 Embed 92

http://www.slideshare.net 92

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…
Post Comment
Edit your comment

    Why Your Selenium Tests are so Dang Brittle, and What to Do About It Why Your Selenium Tests are so Dang Brittle, and What to Do About It Presentation Transcript

    • Why Your Se Tests are So Dang Brittle… …and what to do about it Patrick Wilson-Welsh pwelsh@pillartechnology.com
    • Introduction Patrick Welsh Senior Agile Consultant Pillar Technology Group http://pillartechnology.com pwelsh@pillartechnology.com http://patrickwilsonwelsh.com http://coderetreat.ning.com/ mobile: 248 565 6130 twitter: patrickwelsh
    • Caveat Lector: This is a technical webinar. To follow, you’ll need to know Selenium, a bit of Java, xpath, HTML, and a bit of Object Oriented Design. And, I will be gentle. 
    • We‟re here to help …
    • How hard is it to regression test an entire enterprise web app using any web-app- GUI-black-box testing tool?
    • too hard
    • Number #1 Reason Selenium RC, through the web app GUI tests are so brittle?
    • Because you are writing too many of them. Let me put that another way.
    • You are committing too high a percentage of total test-automation and programming resources to that specific kind of automated testing. Have a plan for outgrowing that pattern. Actually, have a fairy tale:
    • 3 kinds of automated tests
    • GUI end-2-end, integration, story, acceptance unit/micro/isolation
    • TCO % of automated testing work
    • good: least investment/ROI good: most investment/ROI
    • least rework & waste; lowest TCO
    • But that’s not your triangle, yet.
    • we often start here
    • good: easy to learn bad: hard to learn for good reason!
    • bad: high TCO, low ROI good: low TCO, high ROI But again, the price
    • So, you’re stuck with more Se testing than you should be doing. That’s ok. So am I.
    • How can we minimize the brittleness of these inherently brittle tests?
    • Following are things that help me and my teams.
    • Don‟t tell me testing is “not your job”
    • Automated testing is everybody’s job. Se tests are written by testers and programmers together. Period. The whole team shares sufficient testing as part of Definition of Done.
    • • Use Se only for what it‟s good for • Never record and play back tests • Se IDE is just a sandbox. Not an IDE. • Hand-roll your tests (I use Java) • Use a bit of Object Oriented Design • Separate test code from framework code
    • • Test classes get common setup • Keep test framework code really DRY • Beware test code that is too DRY • Duplication is built into GUI test code • Test-class page flows: “open-coded” • Don‟t fret so much about encapsulation. • Concentrate on test clarity.
    • • Use id or name attributes if you got „em • Use xpath as a last-resort element locator • Use least-brittle xpath patterns • Know the IE xpath pitfalls • Beware of Firebug-Driven Development • Use Singleton Se instance • Use Singleton/static app state, carefully • Consider a PageFlowSequence pattern
    • A principle to consider for Se testing: DRY test framework; “wet” test code.
    • Let’s see some code already.
    • Q/A
    • Our Next Steps • Upcoming Webinars: Please visit pillartechnology.com/events • All of the webinar content is available to your business in a 1-2 day on-site workshop or as a “lunch and learn” format. Please contact us for details. • Visit www.pillartechnology.com/events to access presentation slides and full archived broadcasts of past webinars. • Twitter.com/agilesoftware • Blog: www.pillartechnology.com/blog • LinkedIn: Join the Agile Enthusiast Group on LinkedIn: http://bit.ly/agilegroup • YouTube: http://www.youtube.com/user/PillarTechnology • Phone: (888) 3-pillar • Web: pillartechnology.com • Email: info@pillartechnology.com