Archive for the ‘CompuScriptology’ Category

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.

I have 4 exciting new books about JavaScript, that I’m reading and reviewing.

  1. JavaScript: The Missing Manual, by David McFarland, published by O’Reilly Media, ISBN: 978-0-596-51589-8, 543 pages, US $39.99 ~ A great reference, and tutorial on JavaScript
  2. JavaScript: The Good Parts, by Douglas Crockford, published by O’Reilly Media, ISBN: 978-0-596-51774-8, 153 pages, US $29.99 ~ A solid JavaScript reference and delightfully opinionated how-to manual for avoiding the bad parts of JavaScript and maximizing use of the good parts.
  3. Dojo: The Definitive Guide, by Matthew A. Russell, published by O’Reilly Media, ISBN: 978-0-596-51648-2, 450 pages, US $39.99 ~ The definitive guide for powering up AJAX development techniques with the popular and powerful Dojo JavaScript library.
  4. Mastering Dojo, subtitle – JavaScript and Ajax Tools for Great Web Experiences, by Rawld Gill, Craig Riecke, and Alex Russell, published by the Pragmatic Programmers, Pragmatic Bookshelf, ISBN:978-1-934356-11-1, 555 pages, US $38.95 ~ Dojo is a set of client-side  JavaScript tools that help you build better web applications.

An example of code colorizing MySQL table creation.
This example shows creation of a simple contact list, or client list.

1
2
3
4
5
6
7
8
9
CREATE TABLE IF NOT EXISTS `clients` (
 `id` mediumint(8) unsigned NOT NULL auto_increment,
 `email_address` varchar(72) character set ascii NOT NULL,
 `firstname` varchar(16) character set utf8 NOT NULL,
 `lastname` varchar(20) character set utf8 NOT NULL,
 `date_added` datetime NOT NULL,
 UNIQUE KEY `id` (`id`),
 UNIQUE KEY `email_address` (`email_address`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

What’s up with IS?

I guess IN and IS are considered key words in MySQL and the Geshi Generic Syntax Highlighter colorizing library. Is that a bug in the parsing routine, or what?

Dr. Dobbs Journal published a great article, showing how to implement OpenID for Ruby on Rails.

The author, Jeremy Weiskotten, demonstrates how an OpenID consumer can be implemented using the Ruby on Rails framework. The article provides a short tutorial explaining how OpenID single sign on works, and why it’s important. Next it discusses several issues and complications. The final section provides a solid demonstration tutorial, with plenty of Ruby code examples and some screen shots.