Most Read Latest News Blog Resources

Tips: Test, Test, Testing SWT GUIs




April 25, 2007 — 
No, it's not a stutter. But it is good advice. Test today, test tonight, test tomorrow—

If there's any secret to software development, it's that your applications, your packages and your classes need to be tested often. And not just by you, but by an automated process that can do the same testing a million times and never get tired.

Now it may be you who does or initiates the testing, or it may be a team dedicated to that purpose. In either case, automation is the key. As many know—although I continually find others who don't—JUnit, a regression-testing framework written by Erich Gamma and Kent Beck, is the choice for Java testing. JUnit makes it easy to write tests as Java classes.

And Eclipse makes it even easier by including support of JUnit right in the SDK. For most, testing using JUnit involves creating tests for your classes, packages and applications, that exercise their public APIs. However, what happens when you have an SWT application or an Eclipse View that you want to test? Are you left to do this strictly using visual testing? The answer is no.

SWT GUI testing breaks down into three software groups: commercial, Eclipse and open source. Yes I know Eclipse is open source, but I'm trying to distinguish what already comes with Eclipse from what you can add yourself.

Instantiations has a commercial product called WindowTester that comes in three flavors: WindowTester SWT, WindowTester Swing and WindowTester Pro (combination of the previous two). Using their software, you record your interactions with a GUI and it automatically generates JUnit test cases that you can exercise in the future.

The benefits of using this product are that the test cases it creates are Java code. This makes it easy to read, refactor and customize them, as well as create new ones.

In addition, the tests fit into the JUnit framework most Java developers already know. Exercise the test case as you normally would with JUnit. Be happy in the knowledge that when your test cases pass in the future, your GUI worked the same way as it did when the tests were first created. The only downside? You'll have to pay for the product.

Many don't know that Eclipse's Test and Performance Tools Platform (TPTP) now provides similar capabilities for recording and generating GUI tests. As part of the Technology Preview, you can now download plug-ins for Automated GUI Recording. As their user guide states,

"This tool allows users to record GUI actions in the Eclipse platform and play them back to verify the functionality of their product. It is meant to allow Eclipse developers to automate regression tests that often require many resources to perform repetitive tasks to verify basic functionalities."

One of the main differences with the TPTP approach is that it records a test as an XML document. Like many, I find XML easy to read, refactor and customize, so this format is fine with me. TPTP also has the capability to insert verification hooks, corresponding to a JUnit method with a parameter, which are invoked so one can extract the data of a view, editor or shell, and perform assertions to ensure the correctness of the GUI being tested. In short, the upside is it's free, but the downside is that if you just like straight JUnit testing, you'll need to do some more work.

Abbot is an open-source GUI-testing framework that keeps popping up whenever I do a search for SWT GUI testing. Like the others, it has a record playback mechanism that you can customize and refactor. I've talked with a few people who've had some success with the framework, but I can't say from my own experience if it's a viable alternative to the other two I mentioned. Now at least you know it exists, and that you have some options.

Whichever framework you choose, choose one and use it. And test, test, TEST!


Share this link: http://www.sdtimes.com/link/30440
 

Add comment


Name*
Email*  
Country     


  • Comment
  • Preview
Loading



 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 
Download Current Issue
ISSUE 3/15/2010 PDF

Need Back Issues?
DOWNLOAD HERE

Receive the print Edition?


 
blogs tab
Google Code turns 5
Google Code Turns 5, and adds a Paxos Algorithm to make the system more stable and reliable.
03/17/2010 11:16 AM EST

Test your Visual Studio 2010 know-how
Microsoft is offering free beta certification exams for Visual Studio 2010.
03/17/2010 11:08 AM EST

Microsoft lifts the hood on IE9
Microsoft is previewing IE9.
03/16/2010 01:10 PM EST

 

Events calendar tab
3/22/2010 to 3/25/2010
Santa Clara, Calif.
The Eclipse Foundation

4/12/2010 to 4/14/2010
Las Vegas
Penton Media

4/12/2010 to 4/15/2010
Santa Clara, Calif.
O'Reilly Media

4/19/2010
New York City
Flagg Management

4/25/2010 to 4/28/2010
Overland Park, Kans.
IIUG