Abbot Automated GUI Testing Framework, v0.9.0

This document is the API specification for the Abbot automated GUI testing framework and associated support packages, version 0.9.0

Abbot is a Java GUI testing framework. The framework may be invoked directly from Java code (unit tests), or more simply using XML-based scripts. Both methods are designed to be used with the JUnit testing framework. You can launch a GUI, invoke arbitrary user actions on it, and examine its state. The scripts may be invoked from JUnit or with minor modification any other testing environment.

The Abbot framework also includes the Costello editor, which facilitates editing scripts. The editor also supports recording arbitrary user actions into a script.

The Abbot Framework

Abbot provides a framework for testing your GUI regardless of the current state of your code. If you are doing test-first development with lots of unit testing, then Abbot can provide the developer the tools needed to write individual unit tests. If you have an existing code base without existing unit tests, you can use the scripting level of Abbot to start building functional test scaffolding around your application until it is sufficiently stable to support refactoring and addition of unit tests.

In general, testing with Abbot consists of getting references to GUI components and either performing user actions on those components or making some assertions about their state. To facilitate this process, the framework provides ComponentReferences to get a handle on a GUI component (even when it may not yet exist), and Tester objects, which know how to perform user-level actions on various GUI components.

Robot (the user event generator, and the root of all Testers)

This is the fundamental component of Abbot, "A Better 'Bot". It provides basic component-level events upon which more complex tester objects can be built. In the absence of a specific tester object for a given component, the events provided by the Robot class are sufficient to reconstruct any user actions.

Testers provide component-specific user actions and tests (assertions). This is the class to extend when you need to provide access to a custom GUI component. The base class, abbot.tester.ComponentTester, provides default actions for most common user actions, including clicking a mouse button, selecting from a menu, and typing text. The tester system is easily extensible to provide more specific actions or property lookup for custom components; for example, JTableTester provides an action which selects the cell at a given row, column location. JPopupMenuTester provides a method which returns a list of all the menu items currently on a popup menu.

ComponentReferences

ComponentReferences allow you to use a few known attributes of a component to refer to that component, whether or not the component currently exists or is visible. When tests are run, component references are resolved just in time, at the point where the component itself is actually needed. Component lookup is fuzzy, such that irrelevant changes in attributes (such as position or size of a component) generally won't affect the reference mapping.

Scripts

Scripts are the basic units of test execution in the Abbot framework. In general these consist of component lookup information, component actions (such as menu selections, typed text, etc.), and assertions regarding the GUI's state. Scripts for unit tests may be very simple, while scripts for functional testing may be far more lengthy and complex. See the abbot.script package for more details.

When using a script, all information required to run the test is encapsulated within the script itself, to provide independence from any particular testing environment. This facilitates running the scripts under either the script editor, JUnit, or some other harness.

The ScriptFixture provided for use with JUnit derives from junit.framework.TestCase and is a very simple wrapper to adapt the script to the JUnit testing framework. Scripts may be grouped into a test suite by using the ScriptTestSuite class, which can automatically collect a group of tests into a suite based on file hierarchy, filenames, or other criteria. The preferred method of creating a suite is to derive your test class from ScriptFixture, then have the static "suite" method for that derived class create an instance of ScriptTestSuite which selects for the scripts you wish to group. See the API documentation for details.

Editor (Costello)

A script editor is provided to facilitate creation and maintenance of Abbot scripts. The editor supports live recording of user events to facilitate writing scripts, and can also play them back for debugging.

Recorders

Recorders provide a means for the script editor to capture high-level semantic information instead of basic mouse and key events. Recorders are provided for most standard Swing components, but events will be captured properly even in the absence of a customized Recorder for a given component. The editor supports plug-in recorders to support additional custom components.

The primary Recorder class is the EventRecorder, which calls out to specific instances of SemanticRecorder to record component-specific actions.

Some Features of the Abbot Framework

Some of the features of Abbot that distinguish it from other testing harnesses include the following: