Hi,
We came across this problem too. You can plug in an Exception handler, and then report back to the test and/or fail the test when any exception occurs in the EDT.
It would be good to have this included by default when extending the Fest JUnit test class, as this is all generic code which could default to failing the test.
I've included the code below.
Cheers,
H
Handler:
public class AWTExceptionHandler {
private static ITestExceptionListener currentListener;
public AWTExceptionHandler(){
}
public void handle(final Throwable t) {
currentListener.handleException(t);
}
public static void setExceptionListener(final ITestExceptionListener listener){
currentListener = listener;
}
public static void registerExceptionHandler() {
System.setProperty("sun.awt.exception.handler", AWTExceptionHandler.class.getName());
}
}
The listener interface, implemented by the test:
Interface:
public interface ITestExceptionListener {
void handleException(Throwable t);
}
Test:
@Override
public void handleException(final Throwable t) {
this.awtException = throwable;
}
Then in the test @Before:
AWTExceptionHandler.registerExceptionHandler();
AWTExceptionHandler.setExceptionListener(this);
And finally in the @After method:
Assert.assertNull("Exception caught in AWT Thread during test!", awtException);