Package org.testng
Class TestListenerAdapter
- java.lang.Object
-
- org.testng.TestListenerAdapter
-
- All Implemented Interfaces:
IConfigurationListener,IResultListener,IResultListener2,ITestListener,ITestNGListener
- Direct Known Subclasses:
DotTestListener,FailedReporter,TestHTMLReporter,TextReporter,VerboseReporter
public class TestListenerAdapter extends java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<ITestNGMethod>m_allTestMethodsprivate java.util.Collection<ITestResult>m_failedButWSPerTestsprivate java.util.Collection<ITestResult>m_failedConfsprivate java.util.Collection<ITestResult>m_failedTestsprivate java.util.Collection<ITestResult>m_passedConfsprivate java.util.Collection<ITestResult>m_passedTestsprivate java.util.Collection<ITestResult>m_skippedConfsprivate java.util.Collection<ITestResult>m_skippedTestsprivate java.util.Collection<ITestContext>m_testContextsprivate java.util.Collection<ITestResult>m_timedOutTests
-
Constructor Summary
Constructors Constructor Description TestListenerAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeConfiguration(ITestResult tr)Invoked before a configuration method is invoked.protected ITestNGMethod[]getAllTestMethods()java.util.List<ITestResult>getConfigurationFailures()java.util.List<ITestResult>getConfigurationSkips()java.util.List<ITestResult>getFailedButWithinSuccessPercentageTests()java.util.List<ITestResult>getFailedTests()java.util.List<ITestResult>getPassedTests()java.util.List<ITestResult>getSkippedTests()java.util.List<ITestContext>getTestContexts()java.util.Collection<ITestResult>getTimedoutTests()voidonConfigurationFailure(ITestResult itr)Invoked whenever a configuration method failed.voidonConfigurationSkip(ITestResult itr)Invoked whenever a configuration method was skipped.voidonConfigurationSuccess(ITestResult itr)Invoked whenever a configuration method succeeded.voidonFinish(ITestContext testContext)Invoked after all the test methods belonging to the classes inside the <test> tag have run and all their Configuration methods have been called.voidonStart(ITestContext testContext)Invoked before running all the test methods belonging to the classes inside the <test> tag and calling all their Configuration methods.voidonTestFailedButWithinSuccessPercentage(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.voidonTestFailedWithTimeout(ITestResult tr)Invoked each time a test fails due to a timeout.voidonTestFailure(ITestResult tr)Invoked each time a test fails.voidonTestSkipped(ITestResult tr)Invoked each time a test is skipped.voidonTestStart(ITestResult result)Invoked each time before a test will be invoked.voidonTestSuccess(ITestResult tr)Invoked each time a test succeeds.voidsetAllTestMethods(java.util.List<ITestNGMethod> allTestMethods)voidsetFailedButWithinSuccessPercentageTests(java.util.List<ITestResult> failedButWithinSuccessPercentageTests)voidsetFailedTests(java.util.List<ITestResult> failedTests)voidsetPassedTests(java.util.List<ITestResult> passedTests)voidsetSkippedTests(java.util.List<ITestResult> skippedTests)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.testng.IConfigurationListener
beforeConfiguration, onConfigurationFailure, onConfigurationSkip, onConfigurationSuccess
-
-
-
-
Field Detail
-
m_allTestMethods
private java.util.Collection<ITestNGMethod> m_allTestMethods
-
m_passedTests
private java.util.Collection<ITestResult> m_passedTests
-
m_failedTests
private java.util.Collection<ITestResult> m_failedTests
-
m_skippedTests
private java.util.Collection<ITestResult> m_skippedTests
-
m_failedButWSPerTests
private java.util.Collection<ITestResult> m_failedButWSPerTests
-
m_testContexts
private java.util.Collection<ITestContext> m_testContexts
-
m_failedConfs
private java.util.Collection<ITestResult> m_failedConfs
-
m_skippedConfs
private java.util.Collection<ITestResult> m_skippedConfs
-
m_passedConfs
private java.util.Collection<ITestResult> m_passedConfs
-
m_timedOutTests
private java.util.Collection<ITestResult> m_timedOutTests
-
-
Method Detail
-
onTestSuccess
public void onTestSuccess(ITestResult tr)
Description copied from interface:ITestListenerInvoked each time a test succeeds.- Specified by:
onTestSuccessin interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test- See Also:
ITestResult.SUCCESS
-
onTestFailure
public void onTestFailure(ITestResult tr)
Description copied from interface:ITestListenerInvoked each time a test fails.- Specified by:
onTestFailurein interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test- See Also:
ITestResult.FAILURE
-
onTestSkipped
public void onTestSkipped(ITestResult tr)
Description copied from interface:ITestListenerInvoked each time a test is skipped.- Specified by:
onTestSkippedin interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test- See Also:
ITestResult.SKIP
-
onTestFailedWithTimeout
public void onTestFailedWithTimeout(ITestResult tr)
Description copied from interface:ITestListenerInvoked each time a test fails due to a timeout.- Specified by:
onTestFailedWithTimeoutin interfaceITestListener- Parameters:
tr-ITestResultcontaining information about the run test
-
onTestFailedButWithinSuccessPercentage
public void onTestFailedButWithinSuccessPercentage(ITestResult tr)
Description copied from interface:ITestListenerInvoked each time a method fails but has been annotated with successPercentage and this failure still keeps it within the success percentage requested.- Specified by:
onTestFailedButWithinSuccessPercentagein interfaceITestListener- Parameters:
tr-ITestResultcontaining 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:ITestListenerInvoked before running all the test methods belonging to the classes inside the <test> tag and calling all their Configuration methods.- Specified by:
onStartin interfaceITestListener- Parameters:
testContext- The test context
-
onFinish
public void onFinish(ITestContext testContext)
Description copied from interface:ITestListenerInvoked after all the test methods belonging to the classes inside the <test> tag have run and all their Configuration methods have been called.- Specified by:
onFinishin interfaceITestListener- Parameters:
testContext- The test context
-
getFailedButWithinSuccessPercentageTests
public java.util.List<ITestResult> getFailedButWithinSuccessPercentageTests()
- Returns:
- Returns the failedButWithinSuccessPercentageTests.
-
getFailedTests
public java.util.List<ITestResult> getFailedTests()
- Returns:
- Returns the failedTests.
-
getPassedTests
public java.util.List<ITestResult> getPassedTests()
- Returns:
- Returns the passedTests.
-
getSkippedTests
public java.util.List<ITestResult> getSkippedTests()
- Returns:
- Returns the skippedTests.
-
getTimedoutTests
public java.util.Collection<ITestResult> getTimedoutTests()
- Returns:
- Returns the tests that failed due to a timeout
-
setAllTestMethods
public void setAllTestMethods(java.util.List<ITestNGMethod> allTestMethods)
- Parameters:
allTestMethods- The allTestMethods to set.
-
setFailedButWithinSuccessPercentageTests
public void setFailedButWithinSuccessPercentageTests(java.util.List<ITestResult> failedButWithinSuccessPercentageTests)
- Parameters:
failedButWithinSuccessPercentageTests- The failedButWithinSuccessPercentageTests to set.
-
setFailedTests
public void setFailedTests(java.util.List<ITestResult> failedTests)
- Parameters:
failedTests- The failedTests to set.
-
setPassedTests
public void setPassedTests(java.util.List<ITestResult> passedTests)
- Parameters:
passedTests- The passedTests to set.
-
setSkippedTests
public void setSkippedTests(java.util.List<ITestResult> skippedTests)
- Parameters:
skippedTests- The skippedTests to set.
-
onTestStart
public void onTestStart(ITestResult result)
Description copied from interface:ITestListenerInvoked each time before a test will be invoked. TheITestResultis only partially filled with the references to class, method, start millis and status.- Specified by:
onTestStartin interfaceITestListener- Parameters:
result- the partially filledITestResult- See Also:
ITestResult.STARTED
-
getTestContexts
public java.util.List<ITestContext> getTestContexts()
-
getConfigurationFailures
public java.util.List<ITestResult> getConfigurationFailures()
-
onConfigurationFailure
public void onConfigurationFailure(ITestResult itr)
Description copied from interface:IConfigurationListenerInvoked whenever a configuration method failed.- Specified by:
onConfigurationFailurein interfaceIConfigurationListener- Parameters:
itr- The test result- See Also:
IConfigurationListener.onConfigurationFailure(org.testng.ITestResult)
-
getConfigurationSkips
public java.util.List<ITestResult> getConfigurationSkips()
-
beforeConfiguration
public void beforeConfiguration(ITestResult tr)
Description copied from interface:IConfigurationListenerInvoked before a configuration method is invoked.- Specified by:
beforeConfigurationin interfaceIConfigurationListener- Parameters:
tr- The test result
-
onConfigurationSkip
public void onConfigurationSkip(ITestResult itr)
Description copied from interface:IConfigurationListenerInvoked whenever a configuration method was skipped.- Specified by:
onConfigurationSkipin interfaceIConfigurationListener- Parameters:
itr- The test result- See Also:
IConfigurationListener.onConfigurationSkip(org.testng.ITestResult)
-
onConfigurationSuccess
public void onConfigurationSuccess(ITestResult itr)
Description copied from interface:IConfigurationListenerInvoked whenever a configuration method succeeded.- Specified by:
onConfigurationSuccessin interfaceIConfigurationListener- Parameters:
itr- The test result- See Also:
IConfigurationListener.onConfigurationSuccess(org.testng.ITestResult)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-