Package org.testng
Class TestListenerAdapter
- java.lang.Object
-
- org.testng.TestListenerAdapter
-
- All Implemented Interfaces:
IConfigurationListener
,IConfigurationListener2
,IResultListener
,IResultListener2
,ITestListener
,ITestNGListener
- Direct Known Subclasses:
DotTestListener
,FailedReporter
,TestHTMLReporter
,TextReporter
,VerboseReporter
public class TestListenerAdapter extends Object implements IResultListener2
A simple ITestListener adapter that stores all the tests that were run. You can retrieve these results with the following methods: getPassedTests() getFailedTests() getSkippedTests() If you extend this class in order to override any of these methods, remember to call their super equivalent if you want this list of tests to be maintained.- Author:
- Cedric Beust, Aug 6, 2004, Alexandru Popescu
-
-
Constructor Summary
Constructors Constructor Description TestListenerAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeConfiguration(ITestResult tr)
Invoked before a configuration method is invoked.protected ITestNGMethod[]
getAllTestMethods()
List<ITestResult>
getConfigurationFailures()
List<ITestResult>
getConfigurationSkips()
List<ITestResult>
getFailedButWithinSuccessPercentageTests()
List<ITestResult>
getFailedTests()
List<ITestResult>
getPassedTests()
List<ITestResult>
getSkippedTests()
List<ITestContext>
getTestContexts()
void
onConfigurationFailure(ITestResult itr)
Invoked whenever a configuration method failed.void
onConfigurationSkip(ITestResult itr)
Invoked whenever a configuration method was skipped.void
onConfigurationSuccess(ITestResult itr)
Invoked whenever a configuration method succeeded.void
onFinish(ITestContext testContext)
Invoked after all the tests have run and all their Configuration methods have been called.void
onStart(ITestContext testContext)
Invoked after the test class is instantiated and before any configuration method is called.void
onTestFailedButWithinSuccessPercentage(ITestResult tr)
Invoked each time a method fails but has been annotated with successPercentage and this failure still keeps it within the success percentage requested.void
onTestFailure(ITestResult tr)
Invoked each time a test fails.void
onTestSkipped(ITestResult tr)
Invoked each time a test is skipped.void
onTestStart(ITestResult result)
Invoked each time before a test will be invoked.void
onTestSuccess(ITestResult tr)
Invoked each time a test succeeds.void
setAllTestMethods(List<ITestNGMethod> allTestMethods)
void
setFailedButWithinSuccessPercentageTests(List<ITestResult> failedButWithinSuccessPercentageTests)
void
setFailedTests(List<ITestResult> failedTests)
void
setPassedTests(List<ITestResult> passedTests)
void
setSkippedTests(List<ITestResult> skippedTests)
String
toString()
-
-
-
Method Detail
-
onTestSuccess
public void onTestSuccess(ITestResult tr)
Description copied from interface:ITestListener
Invoked each time a test succeeds.- Specified by:
onTestSuccess
in interfaceITestListener
- Parameters:
tr
-ITestResult
containing information about the run test- See Also:
ITestResult.SUCCESS
-
onTestFailure
public void onTestFailure(ITestResult tr)
Description copied from interface:ITestListener
Invoked each time a test fails.- Specified by:
onTestFailure
in interfaceITestListener
- Parameters:
tr
-ITestResult
containing information about the run test- See Also:
ITestResult.FAILURE
-
onTestSkipped
public void onTestSkipped(ITestResult tr)
Description copied from interface:ITestListener
Invoked each time a test is skipped.- Specified by:
onTestSkipped
in interfaceITestListener
- Parameters:
tr
-ITestResult
containing information about the run test- See Also:
ITestResult.SKIP
-
onTestFailedButWithinSuccessPercentage
public void onTestFailedButWithinSuccessPercentage(ITestResult tr)
Description copied from interface:ITestListener
Invoked each time a method fails but has been annotated with successPercentage and this failure still keeps it within the success percentage requested.- Specified by:
onTestFailedButWithinSuccessPercentage
in interfaceITestListener
- Parameters:
tr
-ITestResult
containing information about the run test- See Also:
ITestResult.SUCCESS_PERCENTAGE_FAILURE
-
getAllTestMethods
protected ITestNGMethod[] getAllTestMethods()
-
onStart
public void onStart(ITestContext testContext)
Description copied from interface:ITestListener
Invoked after the test class is instantiated and before any configuration method is called.- Specified by:
onStart
in interfaceITestListener
-
onFinish
public void onFinish(ITestContext testContext)
Description copied from interface:ITestListener
Invoked after all the tests have run and all their Configuration methods have been called.- Specified by:
onFinish
in interfaceITestListener
-
getFailedButWithinSuccessPercentageTests
public List<ITestResult> getFailedButWithinSuccessPercentageTests()
- Returns:
- Returns the failedButWithinSuccessPercentageTests.
-
getFailedTests
public List<ITestResult> getFailedTests()
- Returns:
- Returns the failedTests.
-
getPassedTests
public List<ITestResult> getPassedTests()
- Returns:
- Returns the passedTests.
-
getSkippedTests
public List<ITestResult> getSkippedTests()
- Returns:
- Returns the skippedTests.
-
setAllTestMethods
public void setAllTestMethods(List<ITestNGMethod> allTestMethods)
- Parameters:
allTestMethods
- The allTestMethods to set.
-
setFailedButWithinSuccessPercentageTests
public void setFailedButWithinSuccessPercentageTests(List<ITestResult> failedButWithinSuccessPercentageTests)
- Parameters:
failedButWithinSuccessPercentageTests
- The failedButWithinSuccessPercentageTests to set.
-
setFailedTests
public void setFailedTests(List<ITestResult> failedTests)
- Parameters:
failedTests
- The failedTests to set.
-
setPassedTests
public void setPassedTests(List<ITestResult> passedTests)
- Parameters:
passedTests
- The passedTests to set.
-
setSkippedTests
public void setSkippedTests(List<ITestResult> skippedTests)
- Parameters:
skippedTests
- The skippedTests to set.
-
onTestStart
public void onTestStart(ITestResult result)
Description copied from interface:ITestListener
Invoked each time before a test will be invoked. TheITestResult
is only partially filled with the references to class, method, start millis and status.- Specified by:
onTestStart
in interfaceITestListener
- Parameters:
result
- the partially filledITestResult
- See Also:
ITestResult.STARTED
-
getTestContexts
public List<ITestContext> getTestContexts()
-
getConfigurationFailures
public List<ITestResult> getConfigurationFailures()
-
onConfigurationFailure
public void onConfigurationFailure(ITestResult itr)
Description copied from interface:IConfigurationListener
Invoked whenever a configuration method failed.- Specified by:
onConfigurationFailure
in interfaceIConfigurationListener
- See Also:
IConfigurationListener.onConfigurationFailure(org.testng.ITestResult)
-
getConfigurationSkips
public List<ITestResult> getConfigurationSkips()
-
beforeConfiguration
public void beforeConfiguration(ITestResult tr)
Description copied from interface:IConfigurationListener2
Invoked before a configuration method is invoked.- Specified by:
beforeConfiguration
in interfaceIConfigurationListener2
-
onConfigurationSkip
public void onConfigurationSkip(ITestResult itr)
Description copied from interface:IConfigurationListener
Invoked whenever a configuration method was skipped.- Specified by:
onConfigurationSkip
in interfaceIConfigurationListener
- See Also:
IConfigurationListener.onConfigurationSkip(org.testng.ITestResult)
-
onConfigurationSuccess
public void onConfigurationSuccess(ITestResult itr)
Description copied from interface:IConfigurationListener
Invoked whenever a configuration method succeeded.- Specified by:
onConfigurationSuccess
in interfaceIConfigurationListener
- See Also:
IConfigurationListener.onConfigurationSuccess(org.testng.ITestResult)
-
-