30. ACTUALLY...
There are many kinds of
automated tests
http://www.flickr.com/photos/60648084@N00/1360619915/
31. UNIT TESTS
* For individual functions
* The cutest test.
http://www.flickr.com/photos/donsolo/2900765675/in/set-72157594163175020/
32. INTEGRATION TESTS
* For groups of related
functionality
* More relevant and
(almost) fun to write
http://www.flickr.com/photos/donsolo/399501571/in/set-72157594163175020/
33. ACCEPTANCE TESTS
* Highest level
testing.
* Basically user
stories.
* “Accepted” as in
“get fired if they
don’t work”
http://www.flickr.com/photos/donsolo
43. HOORAY FOR USER STORIES!
Strive to pass good user-centered tests.
http://www.lukeredpath.co.uk/blog/developing-a-rails-model-using-bdd-and-rspec-part-1.html
52. why:
It’s a Firefox plugin for testing.
Turns your actions into test code.
Let’s you edit test code in the browser.
Let’s you export to lots of languages.
54. why:
It’s a Firefox plugin for testing.
Turns your actions into test code.
Let’s you edit test code in the browser.
Let’s you export to lots of languages.
56. why:
It’s a Firefox plugin for testing.
Turns your actions into test code.
Let’s you edit test code in the browser.
Let’s you export to lots of languages.
60. Now: Record and Playback
• Intelligent field selection will use IDs, names, or
XPath as needed
• Autocomplete for all common Selenium
commands
• Walk through tests
• Debug and set breakpoints
• Save tests as HTML, Ruby scripts, or any other
format
Totally takes 5 seconds, man
65. SPEAK SELENESE
open
opens a page using a URL.
click/clickAndWait
performs a click operation, and
optionally waits for a new page to
load.
verifyTitle/assertTitle
verifies an expected page title.
verifyTextPresent
verifies expected text is
somewhere on the page.
66. VERIFY PAGE ELEMENTS
is ...
1. an element is present somewhere on the page?
2. specific text is somewhere on the page?
3. specific text is at a specific location on the page?
67. GOTCHAS
• clickAndWait is usually
required
• type usually requires you
to click somewhere else first
• it’s slow
• brittle if the UI is changing
rapidly
68. HARD PART’S JUST FINDING IT
Good thing you have so many options ...
• find elements by name
• find them by id if they have it
• or with CSS selectors if you understand the cascade
• Xpath is like a buzzsaw (a little more expensive)
• link text as a last resort (since it changes often)
75. Selenium-RC leverages the full power of
programming languages, creating tests that
can do things like
• read and write external files,
• make queries to a database,
• send emails with test reports
• practically
anything else a user can do
with a normal application ...
76. RC can where IDE can’t
• condition statements
• iteration
• logging and reporting of test results
• error handling, particularly unexpected errors
• database testing
• test case grouping
• re-execution of failed tests
• test case dependency
• capture screenshots on test failures
77. WAIT, WHAT ABOUT TEST-
DRIVEN DEVELOPMENT?
If you click around the app to build a test,
that can’t be testing before development.
78. RIGHT.
You actually should write them beforehand, by hand, just like
you would unit tests. It’s not so scary.
• NUnit for C#
• Junit for Java
• Selenium gem for Ruby
82. WHAT IT MEANS
• Run your unit tests first locally (because they’re fast).
• Checking in your changes triggers the continuous
integration server running your Selenium tests (slow
because they are in the browser).
• Cruise Control gives you a web-based heads up when you
fail or pass tests.
• Joy.
83. THANKS!
:)
Chris Blow
http://unthinkingly.com
User Experience @ Meedan.net