Scripted GUI Testing with Ruby

Book Review: Scripted GUI Testing with Ruby, by Ian Dees, published by Pragmatic Programmers, 192 pages, Aug. 2008, ISBN: 978-1-9343561-8-0, US $34.95

All software should be rigorously tested, during the development process, and before it is released. Automated testing helps software developers, testing teams and quality control (QC) teams perform comprehensive and effective testing, and find bugs quickly. This new book from the Pragmatic Bookshelf (in the Facets of Ruby Series) documents and demonstrates how to use the Ruby scripting language to test user interfaces reliably and repeatedly. The book covers a wide scope of testing needs, including techniques for scripted testing of MS-Windows GUIs, Java platform GUIs (for Linux, Mac, Windows, and others), or for web applications.

Book cover - Scripted GUI Testing with Ruby

Book cover - Scripted GUI Testing with Ruby

This book is a practical, quick moving tutorial based on real life, and real-world GUI applications.  Author Ian Dees says, “This is the book I wish I had four years ago. That’s when I faced the equally unpleasant task of fixing old, broken GUI tests and coaxing a rickety third-party toolkit into running new tests. I started looking for a how-to guide on GUI testing to help me down this road. Unfortunately, there were none.”  So Ian wrote the book he was wishing for.

Mr. Dees points out in the introduction (p.4) that many developers and software professionals have been suspicious or skeptical about test driven development (TDD). However, as he points out, “the important idea in TDD wasn’t the tests; it was the fact that writing the tests forces developers to think through how their code will behave.” After TDD, some people shifted their thought process, and began to speak of “behavior driven development” (BDD).  As it turns out, Ruby is a very powerful and expressive language for scripting tests, and RSpec is a special Ruby tool in the Ruby coders toolbox. “RSpec was the first Ruby implementation of the ideas behind BDD.”

Many examples and test scripts are sprinkled throughout the book.

Chapter 2 covers some simple examples with MS-Windows, and Java Swing (the original Sun Java GUI widgets) with JRuby and lays a nice foundation for the variety of tests that can be performed with Ruby.

Chapter 3 provides more in depth coverage of how to use RSpec, which is a Ruby gem (or library), that turns Ruby into a powerful (yet simple) test description language. RSpec notation uses words like “describe” – for describing the test, and “should” – a verb for describing how if the test passes or fails.

Chapter 4 provides details on how to simplify your testing, and Chapter 5 provides many examples for special cases like testing passwords, wrangling documents, cutting and pasting, or searching and replacing  (all under Ruby script control) to exercise many different tests of your application.

Chapter 6 and 7 provide more details about testing many kinds of apps, testing your tests, testing keystrokes, menus, mouse-clicks, and how to introduce randomness into the testing scenario.  Chapter 8 delves into using FIT (Ward Cunningham’s Framework for Integrated Testing). Fortunately, there is a Ruby gem for FIT testing also, and Mr. Dees demonstrates how easy it is to utilize simple HTML tables to visualize your testing.

Chapter 9 moves into testing web applications by impersonating a browser, parsing the HTML, or driving the actual browser to perform specific behaviors. There are several great pointers and examples on how to use Selenium, and Selenium with RSpec, and example scenarios with AJAX also (going way beyond the simple HTML page load tests). Another great Ruby browser/web-site testing tool called Watir (Web Application Testing in Ruby) is also described. This is a great chapter. The testing techniques in chapter 9 are worth the price of the book, so if you buy the book, and only read chapter 9, you will be receiving great value.

The book has several more chapters describing RSpec Story Runner, specialized testing on the MAC, and alternate GUI testing for the MS-Windows platform, with Win32::GuiTest. The book concludes with a bibliography, nice summary of resources, and helpful websites related to Ruby and software testing, and an index of contents in the book.

Bonus: Rails Podcasts has an MP3 you can download – an interview with author Ian Dees about Scripted GUI Testing with Ruby.

Students Promote Blue Beanie Day / Web Standards

Students in Web Application Design course at Bryn Mawr College

Students in the Web Application Design and Development course at Bryn Mawr College wear blue beanies in support of Web Standards!

This photo is one of many from the 2008 Blue Beanie Day collection at Flickr.

You can read more about the history and purpose of Blue Beanie Day 2008 here on vvn.net, Jeffrey Zeldman’s recent post about Blue Beanie Day, or Marshall Kirkpatrick’s Read-Write-Web news article about Blue Beanie Day 2008 and web standards.

A Little CSS for Blue Beanie Day

A Little CSS for Blue Beanie Day

Paul Cripps posted this cute photo to the Blue Beanie Day 2008 collection on Flickr.

The book cover shown is from Cascading Style Sheets – The Definitive Guide, 2nd Edition, by Eric Meyer. You can see Eric Meyer wearing a Blue Beanie here also.

Jason Beaird of Refresh Columbia recently quipped that Zeldman’s Blue Beanie image “is now the Che Guevara icon for web standards revolution.”  The Blue Beanie Day symbol (in the context of Web Standards) was made famous by the original Standardista ( Jeffrey Zeldman ) and his book covers.

Blue Beanie Day 2008

Blue Beanie Day 2007 - Photo in Doug Vos basement library

Blue Beanie Day 2007 - Photo in Doug Vos basement library

The second annual Blue Beanie Day will be celebrated on Friday, November 28, 2008

Thousands of Standardistas (people who support web standards) will wear a Blue Beanie to show their support for accessible, semantic web content.

It’s easy to show your support for web design done right. Beg, borrow, or buy a Blue Beanie and snap a photo of your mug wearing the blue. (Or get creative with Photoshop). Then on November 28, switch your profile picture in Facebook, Twitter, Flickr, (and any other social network) and post your photo to the Blue Beanie Day group at Flickr: http://www.flickr.com/groups/bluebeanieday2008/ .

It’s easy to participate:

  1. Make a personal commitment to fight Web Standards apathy. Show solidarity with the Standardistas on Friday, November 28th, 2008.
  2. Buy, beg, or borrow a Blue Beanie (blue hat or cap, even a black or grey one will do in a pinch.)
  3. Take a photo of yourself wearing the Blue Beanie. Or take a cool group photo of you and your friends wearing Blue Beanies.
  4. Post your photo, or photos to Facebook, Flickr, Twitter, and other social networks on Friday, November 28th, 2008. Remember to switch your Facebook profile photo that day.
  5. Promote Blue Beanie Day in your blog or wiki starting today, and tell all your friends to get ready for Blue Beanie Day. Start by inviting all your Facebook friends to this event.

Historical notes and relate links:

  1. Flickr photostream from Blue Beanie Day 2007
  2. Twitter tweets (comments) on the topic of Blue Beanie Day.
  3. Background on Designing With Web Standards (DWWS) group on Facebook.
  4. My blog entry on the original Blue Beanie Day – 2007.