Skip to end of metadata
Go to start of metadata

FEST-Swing can take a screenshot of the desktop when a TestNG GUI test fails. Because of TestNG's excellent support for extensibility, it is quite easy to setup FEST-Swing with TestNG.

Note: To use FEST-Swing's TestNG extension, you'll need to include the file fest-swing-testng-VERSION.jar in your classpath.

The provided listener, org.fest.swing.testng.ScreenshotOnFailureListener, is capable of taking a screenshot of the desktop when a test fails and saves it in TestNG's default output directory. Due to TestNG's flexible architecture, this listener can be called either from Ant, TestNG plug-in for Eclipse, command line, etc.

To take screenshots of failed GUI tests, regardless of how they are executed, please follow these steps:

  1. Add the TestNG Extension to your classpath (file fest-swing-testng-{VERSION}.jar, included when you download FEST-Swing)
  2. Mark GUI tests (class or method level) with the annotation GUITest.

The following example shows how to register a ScreenshotOnFailureListener with TestNG Ant task:

The following is a screenshot of a failed TestNG GUI test:

For more details about using TestNG listeners, please visit TestNG's documentation.