eXtreme GUI Software Testing (Part 2)

As I mentioned in a previous blog entry (eXtreme GUI Testing, Part 1) I've been motivated to work on a project in my spare time, and I'd like to start leaking the details here.

For lack of a better name I'm currently calling this project eXtreme GUI Tester, or XGT for short. As its name implies, this is an application (actually a suite of applications) that hopes to make automated GUI testing a little more of a reality.

XGT - eXtreme GUI Testing

XGT consists of two main parts. First, there is a GUI Testing Recorder (the XGT Recorder) that lets you record your interactions with the GUI application you're testing. The aim of the recorder is to let you record your interactions with any application as rapidly as possible (web application, client/server, whatever).

The Recorder creates a plain-text script file that can then be played by the XGT Player. The GUI Testing Player plays back scripts that you've recorded. Besides being plain text, the scripts themselves are actually ... drumroll ... Ruby programs!

(Pause to let that sink in.)

Okay, I lied ... they are really JRuby programs.

(Additional pause.)

Because they are Ruby/JRuby programs, they are:

  1. Plain text, meaning that you can edit them and customize them to your heart's content.
  2. You can also take advantage of the power of the Ruby syntax to do, well, anything you want.
  3. Finally, because they are JRuby programs, you also have all the power of the Java language at your fingertips as well.

Given Ruby and Java as my languages, I don't think I'll be lacking for power or flexibility with JRuby as my scripting language.

A simple XGT GUI testing script

Okay, sounds cool, but "What do the scripts look like?" you ask. Let's take a look. Here's a sample script:

require 'java'
require 'XGTPlayer'
require 'MyOrderEntryCommands'

# and the script begins ...
show_desktop

# search the desktop for this icon, then double-click it
doubleclick_image 'application_logo.png'

# the player waits until it sees the application running
wait_for_application_to_start

# now, just for grins, let's create the same order three times
3.times {
  go_to_main_menu
  comment 'creating a new order'
  create_new_order
  lookup_customer
  add_xlarge_pepperoni_pizza
  add_large_cheese_pizza
  add_breadsticks
  add_2liter_drink
  validate_price
  do_save
}

# with the order done we'll shut down the application
shut_down_application

There you have it, my first public display of an XGT  GUI testing script. Hopefully you can just read those commands, er, Ruby method names, and figure out what this test is doing. I hope you can also see the power of this level of abstraction. This script is very readable, and the details are encapsulated in the methods.

I hope you like how it starts, double-clicking an image it looks for on the screen. That's one of my favorites, and an important part of the abstraction. There are other cool things in the works, like click_save_button, where the code will find a Save button on the screen and click it for you automatically.

Whet your appetite? I hope so. In my next installment I'll start sharing the details of what exactly is encapsulated inside those method calls.

Automated GUI Testing software

June 1, 2010: I've been working on the software again for the last 7-10 days, and it's now available as a project I call "Automated GUI testing software (AGT)".