Abbot the GUI testing tool is very cool.
abbot.sf.net for thoes interested.
I have been experimenting with it for a while now and I think I have a solution to work with legacy Swing code that will work.
Basically
Run the editor to build the scripts
I have built several reuseable scripts like start the app, find the doo-dad etc
I save the scripts in the same location as the test then use a class loader to load the script (see below again)
Then mix and match the scripts in my JUnit test, code below
The JUnit test then ends up looking like this;
protected Script loadScript(String scriptName) throws InvalidScriptException {
URL launchURL = getClass().getClassLoader().getResource(scriptName);
Script script = new Script();
try {
script.load(new InputStreamReader(launchURL.openStream()));
} catch (InvalidScriptException e) {
e.printStackTrace();
throw e;
} catch (IOException e) {
e.printStackTrace();
throw new InvalidScriptException(e.getMessage());
}
return script;
}
public void testLaunch() throws Throwable {
Script launch = loadScript("test/gui/abbot/StartTheApp.xml");
Script terminate = loadScript("test/gui/abbot/StopTheApp.xml");
StepRunner runner = new StepRunner();
runner.run(launch);
Thread.sleep(3000);
runner.run(terminate);
}
Then with this I can mix and match the scripts all I want. I can create 'reuseable' scripts then put them together in ways to try to break the app.
This approach is similar to http://jameleon.sourceforge.net/ but its focused on Swing GUI's. If I ever get time I'll have to send email to Timothy Wall about this approach and see what he thinks, perhaps I could contribute some of the 'infrastructure' of this to Abbot.