Please follow these tips to make sure that your GUI tests respect Swing's threading rules:
- Read about Swing's threading rules. In short, the cardinal rule is: creation and access of Swing components should be done in the Event Dispatch Thread (EDT.)
- Creation and any direct access to Swing components should be done via
GuiTask, because JUnit and TestNG tests do not run on the EDT. More details can be found here.
- Access of Swing components through FEST APIs is already EDT-safe.
- It is strongly recommended to use
FailOnThreadViolationRepaintManagerto catch EDT-access violations. More details can be found here.
Many thanks to Eric Kolotyluk, for pointing out the need to document this important information.
Update: A detailed list of tips on how to write EDT-safe GUI tests can be found here.