Abbot Topics

Abbot framework for automated testing of Java GUI components and programs
All materials Copyright 2002-2011 Timothy Wall, All Rights Reserved

This version 1.2.0

Quick Start

If you haven't done so yet, download the abbot package [tgz] [zip] (which includes source). Simply unpack and refer to the Quick Start information below.

  1. Launch the script editor.

java -jar lib/costello.jar

NOTE: Under some 1.3 VMs using X11, the splash screen may trigger a VM bug. If this is the case, invoke as "java -cp lib/costello.jar abbot.editor.ScriptEditor" instead.

2.      Create a new script.
Select File->New Script from the menu bar to get a new script with default launch and terminate steps (you will first be prompted for a file to save it in). Launch defines a class and method to invoke to launch your GUI. Terminate disposes of all GUI components generated by the launch step.

3.      Launch the GUI.
Edit the launch line to launch some sample code. For example, to invoke the main(String[] args) method in class example.MyCode with no arguments, you would edit the launch step to look like this:

In the interest of keeping scripts self-contained, it is recommended that you specify the classpath in the script rather than depending on the VM classpath argument or the environment classpath. See the Launch step for usage details. Now you can use Test->Launch to display the GUI under test. The example code will display a frame with a variety of sample components.

4.      Record some user actions.
Select Capture->All Actions (or shift+F2), and perform some user actions in the GUI. If you haven't already launched the GUI, the editor will launch it for you. The editor will detect as many high-level semantic events as it can and insert raw mouse motion and button events for what it doesn't recognize. When you get the GUI to a point that you want to make some tests of its state, press shift+F2 or activate the editor window to suspend recording. The recording so far will be inserted into the script as a sequence of steps.

5.      Add some assertions.
Move the mouse over the component in your GUI for which you'd like to add a test and press shift+F1. That component will be selected in the component browser tree in the bottom half of the script editor. The hierarchy view presents the full hierarchy of components that have been created. Once you've selected a component, its associated properties will appear in the pane to the right. Select a property ("Text" on a JButton, for instance), then click the Assert equals button to insert an assertion into the test. Repeat as necessary for other components, or press shift+F2 to continue recording actions. Note that if a component you'd like to test is within a modal dialog, you'll need to explicitly add a reference with alt+shift+F1 and add the assertion after the dialog has been dismissed.

6.      Run the script.
The script editor also allows you to run the script, recording any test failures or errors. Each step will be highlighted as it is played back, with failures and errors highlighed in red.

When you've generated several tests and want to incorporate them into a JUnit suite, you will want to derive from ScriptFixture to provide a custom ScriptTestSuite which will identify which scripts belong in the suite. ScriptFixture is a simple JUnit test case wrapper around an Abbot test script. The only thing you really need to do is return an inner ScriptTestSuite instance in the static "suite" method.

See the Costello user's guide for more detail.

---

 

This project generously hosted by
SourceForge Logo

 


Click to subscribe to java-gui-testing