Skip to end of metadata
Go to start of metadata

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."

Installing 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.

Once a FailOnThreadViolationRepaintManager is installed, it will throw a EdtViolationException if a GUI test is not accessing Swing components in the EDT.

1 Comment

  1. There is a typo. The method (setUpOnce here) with @BeforeClass annotation has to be public static or @Before annotation has to be used for non-static methods instead.