AssertJ Swing can take screenshots of the desktop when a TestNG GUI test fails. Because of TestNG's excellent support for extensibility, this extension is very easy to configure.

The provided listener, {@link org.assertj.swing.testng.listener.ScreenshotOnFailureListener}, takes 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: