FEST provides the class
FailOnThreadViolationRepaintManager that forces a test failure if access to Swing components is not performed on the EDT. This
RepaintManager on based on
ThreadCheckingRepaintManager by Scott Delap and Alex Potochkin. For more details about how to check if GUI component is done outside the EDT, please check Alex Potochkin's excellent article "Debugging Swing, the final summary."
FailOnThreadViolationRepaintManager is pretty simple. The following example shows how to install it in the class-level setup method of a TestNG test:
When using Sun's JVM, a new instance of
FailOnThreadViolationRepaintManager will be set as the default repaint manager in Swing once and only once, regardless of the number of times install is called. On other JVMs this optimization is not guaranteed.
FailOnThreadViolationRepaintManager is installed, it will throw a
EdtViolationException if a GUI test is not accessing Swing components in the EDT.