Package org.testng
Class TestListenerAdapter
java.lang.Object
org.testng.TestListenerAdapter
- All Implemented Interfaces:
IConfigurationListener
,IResultListener
,IResultListener2
,ITestListener
,ITestNGListener
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
FieldsModifier and TypeFieldDescriptionprivate Collection<ITestNGMethod>
private Collection<ITestResult>
private final Collection<ITestResult>
private Collection<ITestResult>
private final Collection<ITestResult>
private Collection<ITestResult>
private final Collection<ITestResult>
private Collection<ITestResult>
private final Collection<ITestContext>
private final Collection<ITestResult>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked before a configuration method is invoked.protected ITestNGMethod[]
void
Invoked whenever a configuration method failed.void
Invoked whenever a configuration method was skipped.void
Invoked whenever a configuration method succeeded.void
onFinish
(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.void
onStart
(ITestContext testContext) Invoked before running all the test methods belonging to the classes inside the <test> tag and calling all their Configuration methods.void
Invoked each time a method fails but has been annotated with successPercentage and this failure still keeps it within the success percentage requested.void
Invoked each time a test fails due to a timeout.void
Invoked each time a test fails.void
Invoked each time a test is skipped.void
onTestStart
(ITestResult result) Invoked each time before a test will be invoked.void
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) toString()
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 Details
-
m_allTestMethods
-
m_passedTests
-
m_failedTests
-
m_skippedTests
-
m_failedButWSPerTests
-
m_testContexts
-
m_failedConfs
-
m_skippedConfs
-
m_passedConfs
-
m_timedOutTests
-
-
Constructor Details
-
TestListenerAdapter
public TestListenerAdapter()
-
-
Method Details
-
onTestSuccess
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:
-
onTestFailure
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:
-
onTestSkipped
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:
-
onTestFailedWithTimeout
Description copied from interface:ITestListener
Invoked each time a test fails due to a timeout.- Specified by:
onTestFailedWithTimeout
in interfaceITestListener
- Parameters:
tr
-ITestResult
containing information about the run test
-
onTestFailedButWithinSuccessPercentage
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:
-
getAllTestMethods
-
onStart
Description copied from interface:ITestListener
Invoked before running all the test methods belonging to the classes inside the <test> tag and calling all their Configuration methods.- Specified by:
onStart
in interfaceITestListener
- Parameters:
testContext
- The test context
-
onFinish
Description copied from interface:ITestListener
Invoked 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:
onFinish
in interfaceITestListener
- Parameters:
testContext
- The test context
-
getFailedButWithinSuccessPercentageTests
- Returns:
- Returns the failedButWithinSuccessPercentageTests.
-
getFailedTests
- Returns:
- Returns the failedTests.
-
getPassedTests
- Returns:
- Returns the passedTests.
-
getSkippedTests
- Returns:
- Returns the skippedTests.
-
getTimedoutTests
- Returns:
- Returns the tests that failed due to a timeout
-
setAllTestMethods
- Parameters:
allTestMethods
- The allTestMethods to set.
-
setFailedButWithinSuccessPercentageTests
public void setFailedButWithinSuccessPercentageTests(List<ITestResult> failedButWithinSuccessPercentageTests) - Parameters:
failedButWithinSuccessPercentageTests
- The failedButWithinSuccessPercentageTests to set.
-
setFailedTests
- Parameters:
failedTests
- The failedTests to set.
-
setPassedTests
- Parameters:
passedTests
- The passedTests to set.
-
setSkippedTests
- Parameters:
skippedTests
- The skippedTests to set.
-
onTestStart
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:
-
getTestContexts
-
getConfigurationFailures
-
onConfigurationFailure
Description copied from interface:IConfigurationListener
Invoked whenever a configuration method failed.- Specified by:
onConfigurationFailure
in interfaceIConfigurationListener
- Parameters:
itr
- The test result- See Also:
-
getConfigurationSkips
-
beforeConfiguration
Description copied from interface:IConfigurationListener
Invoked before a configuration method is invoked.- Specified by:
beforeConfiguration
in interfaceIConfigurationListener
- Parameters:
tr
- The test result
-
onConfigurationSkip
Description copied from interface:IConfigurationListener
Invoked whenever a configuration method was skipped.- Specified by:
onConfigurationSkip
in interfaceIConfigurationListener
- Parameters:
itr
- The test result- See Also:
-
onConfigurationSuccess
Description copied from interface:IConfigurationListener
Invoked whenever a configuration method succeeded.- Specified by:
onConfigurationSuccess
in interfaceIConfigurationListener
- Parameters:
itr
- The test result- See Also:
-
toString
-