Skip to end of metadata
Go to start of metadata

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


  1. I'm new to FEST and I think it's a great tool.

    The possibility of taking screenshots seems to be quite useful! There is only one thing which confused me a little bit: The name of the annotation "GUITest" is somehow misleading and I would suggest to call it ScreenshotTest, since all tests with FEST are gui-tests. But since the renaming would cause some problems in terms of compatibility between FEST-versions I think I have to accept this :)

    But the ability to take screenshots is very cool and I like it very much! Thanks for that ;)


  2. Thanks Christian for your feedback! (smile)

    I'd truly appreciate if you could please post this in the mailing list. This way, this topic will be exposed to all FEST users, and we could come up with a better name for the annotation.

    Also, I'm working on a new way to specify that a test is a "screenshot-on-failure test" using JUnit categories. I think this is the best time to make changes to this functionality!