public class ScreenshotOnFailureListener extends AbstractTestListener
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.
Constructor and Description |
---|
ScreenshotOnFailureListener()
Creates a new
. |
Modifier and Type | Method and Description |
---|---|
void |
onStart(org.testng.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(org.testng.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.
|
onFinish, onTestFailedButWithinSuccessPercentage, onTestSkipped, onTestStart, onTestSuccess
public ScreenshotOnFailureListener()
ScreenshotOnFailureListener
.public void onStart(org.testng.ITestContext context)
onStart
in interface org.testng.ITestListener
onStart
in class AbstractTestListener
context
- the given method context.public void onTestFailure(org.testng.ITestResult result)
onTestFailure
in interface org.testng.ITestListener
onTestFailure
in class AbstractTestListener
result
- contains information about the failing test.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.