TestingGUIApplications < Javapedia < TWiki

TWiki . Javapedia . TestingGUIApplications

Home | Help | Changes | Index | Search | Go

TestingGUIApplications

By "GUI Applications" I mean ones where Java draws the GUI (e.g. with Swing or SWT or other technologies), not ones where the application is a servlet or JSP or similar concept running inside a web server. For discussion of testing those applications, see TestingWebApplications. In the java-gui-testing group (http://groups.yahoo.com/group/java-gui-testing/) we regularly get off-topic questions concerning automating tests of Web Applications, so I wanted to clarify the purpose of this page up front.

Test automation tools

A well tested application is going to have greater chance of success. GUI applications are expensive to test because their nature involves human interaction which tends to require manual testing (high expense). With a given budget, the hope is that you can achieve more testing by automating your manual tests. It is my (David Herron) belief that testing, and the existance of automated testing tools for Windows, is an overlooked reason why Windows is so successful in the marketplace. That is, because the Windows platform has a wide choice of GUI test automation tools, this means applications developers for Windows can afford to do more testing, and as a result it's likely they'll find more bugs in their application. Fewer GUI automation tools support other platforms (e.g. Mac OS, Linux, Solaris, other Unixen); one exception is Rational Functional Tester for Linux. Fortunatelly the Java platform has some GUI automation tools, as we see listed here:

Known tools:

Most of these build on the java.awt.Robot class. The Robot class exists to provide the minimal core features required to support any test automation tool. Robot synthesizes native-level events so that when they arrive in the application they appear to be indistinguishable from events created by users playing with their mouse and keyboard. In some cases the automation tools instead send AWT events through the AWT event queue, bypassing the native event layer. There is an important distinction between these approaches in the amount of the Java platform exercised during the test. Obviously a native level event (as produced by Robot) will go through the full AWT "stack" while simply pushing an Event object into the queue does not. Deep in the bowels of AWT there is obviously code that recieves OS-specific events, translating them into AWT event(s). Depending on your testing goals the push AWT events into the queue model may be enough for you, just know that your test will not be "complete" in that it will not cover the whole AWT "stack".

Record/Playback vs. Programmatic

These are the two general styles of GUI automation tools.

This is a long-standing dispute in the testing industry over which method is more appropriate. So it's unlikely we can provide an answer on this web page, so instead let's try and clearly state the pro's and con's of each approach.

Record/Playback

Programmatic

"Hybrid" application testing

One type of scenario these tools do not cover well is hybrid situations where the test involves interactions between Java and native GUI components (such as web browsers containing an applet). In the Applet case, many or most of these tools can be used to automate tests of the Java GUI. However, they cannot automate interaction with the native GUI components. Here's the reasoning:

Obviously a commercial GUI test tool such as Silk,

WinRunner
,
RobotJ
, etc, all are able to automate these scenarios. However, they exist only for the MS Windows operating system. Since Java is cross-platform, this restricts your automated testing only to one of the platforms you might deploy to. This may be okay for you, or it may not.

Image-based component discovery

Most GUI test tools discover GUI components through some kind of hook or Java reflection. However this requires modifying the Java instance, and embedding the GUI test tool into the application may affect the overall execution. Further the technique limits component discovery to the components in the current VM, and if your test needs to interact with multiple applications then you'll be stuck.

There are at least two tools which follow a different approach. They perform component discovery through analyzing screen images. This lets them sit outside the application being tested, and to discover any component anywhere on the screen.

These are:

Non-Java-specific GUI test automation tools

There are several GUI test automation tools which can drive non-Java applications that might also be useful to drive Java applications. Some are commercial, some open source. TBD: Find these and make links and summaries

Articles & such

ClientJava.COM: Jemmy Swing GUI Testing - A presentation given in March 2005 at the St. Louis JUG meeting.

UI Automated Testing of Java Applications - Presentation given in June 2007 at Jazoon07 by Jiri Skrivanek

-- Main.robogeek - 12 Mar 2005



Discussion about TestingGUIApplications

----- Revision r16 - 10 Sep 2007 - 14:12:10 - Main.twalljava