
By Satadip Dutta | Article Rating: |
|
July 18, 2009 12:45 PM EDT | Reads: |
69,447 |
Graphical user interface (GUI) testing is a potentially problematic area because constructing effective test cases is more difficult than the corresponding application logic. The roadblocks to effective functional GUI testing are:
Functional GUI testing needs to deal with GUI events as well as the effects of the underlying application logic that results in changes to the data and presentation.
The common methods for functional GUI testing are the "record and execute" script technique and writing test programs for different scenarios. In the "record and execute," the test designer interacts with the GUI and all the events are recorded in a script. The script can later be replayed to re-create user interactions for a particular scenario. In the test programs, the test designer tries to understand and write tests for the various GUI decision points.
This article discusses how Abbot can be used to quickly and effectively come up with a comprehensive GUI test framework for Swing GUI applications. Abbot (http://abbot.sourceforge.net/) is a JUnit extension for Swing GUI testing. It provides an interesting framework that can be used for test case generation as well as "record and execute" scripting.
Introduction to Abbot
Abbot builds upon the java.awt.Robot class to provide an automated event generation and validation framework for Swing GUI components. The framework can be used to create, record, and execute scripts and programmatic test cases in Java. Abbot also has a script editor called Costello that facilitates the creation of scripts in XML. The framework can also be well integrated to run with JUnit.
To illustrate the use of Abbot to create a GUI test infrastructure, this article will make use of the following two scenarios.
1. GUI already exists: The GUI has been coded and the application needs to be tested, but no unit tests are available. This scenario will primarily make use of the "record and execute" style and then focus on how test suites can be created and run with JUnit.
2. GUI has not been coded: The GUI has been designed on paper; however, no working code exists. This scenario will primarily focus on creating test cases in Java. This method will create a homogeneous suite of tests both for the back-end application code and the GUI.
The two scenarios focus on the end-point cases in functional GUI testing. The principles mentioned can be mixed and matched to suit the needs of the project. To get started with Abbot, download the JAR files and place them in the lib directory of the project.
Scenario One: GUI Already Exists
In this scenario, most of the GUI has already been coded. Automated testing is not available and the testing is mainly being done by hand. The goal is to come up with a test suite in the shortest time possible so that the quality metrics for the project can be met effectively.
The script editor Costello will be used to develop a battery of tests. Costello provides the "record and execute" functionality that will allow us to record different user interaction scenarios with the GUI and test those scenarios efficiently. The scripts that record the user interactions are saved as XML. The salient features of the scripts that help in rapidly creating a functional test framework are:
An example of a test script in XML is provided in Listing 1.
With this background about the features of the script, it's time to look into how to use the script editor to create the test cases. The sample GUI shown in Figure 1 is an example from the Java Swing tutorial available at java.sun.com.
The GUI is a Celsius-to-Fahrenheit converter that takes in a numeric value and on the button click displays the converted result in Fahrenheit. To test this GUI, we can write some simple GUI tests to verify the results on the input of a positive number, a negative number, and a nonnumeric input.
Published July 18, 2009 Reads 69,447
Copyright © 2009 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Satadip Dutta
Satadip Dutta is a software architect at Hewlett-Packard (http://devresource.hp.com) and has been programming in Java since 1997. His areas of interest include distributed software architecture, Web services, and user interface design. Satadip holds an MS in Computer Science from Virginia Tech.
![]() Sep. 6, 2019 09:00 AM EDT |
By Zakia Bouachraoui ![]() Sep. 5, 2019 07:00 PM EDT |
By Zakia Bouachraoui ![]() Sep. 4, 2019 11:15 PM EDT |
By Zakia Bouachraoui ![]() Sep. 4, 2019 11:00 PM EDT Reads: 312 |
By Elizabeth White ![]() Jul. 1, 2019 07:30 AM EDT |
By Zakia Bouachraoui Jun. 27, 2019 08:00 AM EDT |
By Pat Romanski Jun. 24, 2019 06:00 AM EDT |
By Zakia Bouachraoui Jun. 17, 2019 01:00 PM EDT |
By Pat Romanski Jun. 15, 2019 08:15 PM EDT |
By Pat Romanski Jun. 15, 2019 01:00 PM EDT |