org.fest.swing.testng.listener
Class ScreenshotOnFailureListener

java.lang.Object
  extended by org.fest.swing.testng.listener.AbstractTestListener
      extended by org.fest.swing.testng.listener.ScreenshotOnFailureListener
All Implemented Interfaces:
ITestListener, ITestNGListener
Direct Known Subclasses:
ScreenshotOnFailureListener

public class ScreenshotOnFailureListener
extends AbstractTestListener

Understands a TestNG listener that takes a screenshot when a GUI test fails.

Note: A test is consider a GUI test if it is marked with the annotation GUITest.

To use this listener, we just need to make TestNG aware of it. The following is an example using Ant:

 <testng listeners="org.fest.swing.testng.listener.ScreenshotOnFailureListener" outputDir="${target.test.results.dir}" haltOnFailure="true" verbose="2">
   <classfileset dir="${target.test.classes.dir}" includes="**/*Test.class" />
   <classpath location="${target.test.classes.dir}" />
   <classpath location="${target.classes.dir}" />
   <classpath refid="test.classpath" />
 </testng>
 

You can find more information here.

Author:
Alex Ruiz

Constructor Summary
ScreenshotOnFailureListener()
          Creates a new ScreenshotOnFailureListener.
 
Method Summary
 void onStart(ITestContext context)
          Gets the output directory from the given context after the test class is instantiated and before any configuration method is called.
 void onTestFailure(ITestResult result)
          When a test fails, this method takes a screenshot of the desktop and adds an hyperlink to the screenshot it in the HTML test report.
 
Methods inherited from class org.fest.swing.testng.listener.AbstractTestListener
onFinish, onTestFailedButWithinSuccessPercentage, onTestSkipped, onTestStart, onTestSuccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenshotOnFailureListener

public ScreenshotOnFailureListener()
Creates a new ScreenshotOnFailureListener.

Method Detail

onStart

public void onStart(ITestContext context)
Gets the output directory from the given context after the test class is instantiated and before any configuration method is called.

Specified by:
onStart in interface ITestListener
Overrides:
onStart in class AbstractTestListener
Parameters:
context - the given method context.

onTestFailure

public void onTestFailure(ITestResult result)
When a test fails, this method takes a screenshot of the desktop and adds an hyperlink to the screenshot it in the HTML test report.

Specified by:
onTestFailure in interface ITestListener
Overrides:
onTestFailure in class AbstractTestListener
Parameters:
result - contains information about the failing test.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.