On some occasions a functional GUI test will run perfectly from within the IDE but will break when executed in a batch with other tests (such as when you are using Ant). This is because functional GUI tests are vulnerable to certain environment-related events, and FEST-Swing is no exception.

It occasionally may happen that anti-virus software runs a scheduled scan while a GUI is under test. If the anti-virus software pops up a dialog in front of the GUI, the FEST robot will not be able to access the GUI and will time out eventually, making the test fail. In this case, the failure is not related to a programming error; it is just a case of bad timing.

FEST-Swing is capable of taking a screenshot of the desktop when a GUI test fails, regardless of the test framework you use (TestNG or JUnit.) You then can use this screenshot to verify the cause of a failed test and discover whether it is programmatic or environmental.

There are many ways to take a screenshot of the desktop when a GUI test fails. Regardless of how the FEST-Swing takes a screenshot, it needs to know which tests should be considered "GUI tests." In order to do so, we only need to add the annotation @GUITest. This annotation can be placed at class or method level, and it is inherited by subclasses of annotated classes.

Once our GUI tests have the @GUITest annotation, we can take screenshot of the desktop when a GUI test fails:

  1. Manually
  2. FEST's JUnit extension
  3. FEST's TestNG extension