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

Getting Started with the Abbot Java GUI Test Framework

Building unit tests and functional tests (AWTUnit/SwingUnit)

Abbot helps you test your Java UI. It comprises Abbot, which lets you programmatically drive UI components, and Costello (built on Abbot) which allows you to easily launch, explore and control an application. The framework may be used with both scripts and compiled code.

Costello Screen Shot

Costello

Run Costello

(Get Webstart here)

This overview of the Abbot system will give you an idea of the different system components and how it is used. There is also some background concerning the issues involved with Java GUI testing.

You can see what Costello (the script editor) looks like or try it out via Java Web Start by using the links to the right. The screen shot shows a sample application, its UI hierarchy, and some component properties as displayed by Costello.

Here is what GUI unit test code looks like using Abbot (see Tutorial 1 or Tutorial 2 for more examples).

    // Suppose MyComponent has a text field and a button...
    MyComponent comp = new MyComponent();
    // Display a frame containing the given component
    showFrame(comp);

    JTextField textField = (JTextField)getFinder().
        find(new ClassMatcher(JTextField.class));
    JButton button = (JButton)getFinder().find(new Matcher() {
        public boolean matches(Component c) {
            // Add as much information as needed to distinguish the component
            return c instanceof JButton && ((JButton)c).getText().equals("OK");
        }
    });
    JTextComponentTester tester = new JTextComponentTester();
    tester.actionEnterText(textField, "This text is typed in the text field");
    tester.actionClick(button);
    // Perform some tests on the state of your UI or model
    assertEquals("Wrong button tooltip", "Click here to accept", button.getToolTipText());

Refer to the API documentation for the ComponentTestFixture, ComponentTester and Robot classes, as well as the framework tests in the test source subdirectory.

You can also record user actions directly into a script which controls the event playback and testing. This form of test is more suitable to integration/functional testing. The Costello script editor is provided which can record user actions and facilitate script construction and maintenance. It also provides insight into the hierarchy of the application under test. You can launch the editor with the Web Start link above and immediately point it at any application you wish to launch and examine. The editor provides a hieararchy browser which displays all components in use by the application, as well as a wealth of information about any component selected in the hierarchy.

JUnit is used as the controlling harness for running tests and suites of tests, but scripts can easily be wrapped to run in other environments. Scripts may also be used to create a demo or tutorial for an application. You can drive the actual application and provide popup annotations while it is running.

Abbot is provided under the Eclipse Public License (EPL). Contact us via email if you require a different license.

For latest changes, see the latest news and release notes.

Please direct all questions and help requests to the Abbot user's mailing list, after searching the the mailing list archives and older discussions in the SourceForge Forums.

Join the Abbot Mailing List

Click to subscribe to java-gui-testing

 

Get the whole picture at
SourceForge Logo

  For all things Java
Java.net Logo