Package org.apache.pulsar.tests
Class TestRetrySupport
java.lang.Object
org.apache.pulsar.tests.TestRetrySupport
Adds support for resetting the internal state of the test
by calling "cleanup" and "setup" methods before running a test method
after a previous test method has failed.
This is useful for making test retries to work on classes which use BeforeClass
and AfterClass methods to setup a test environment that is shared across all test methods in the test
class.
The setup method implementation must call incrementSetupNumber method and the cleanup method must call
markCurrentSetupNumberCleaned method. This is required by the state tracking logic.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcleanup()Cleans up the state of the environment.final voidfailureCheck(org.testng.ITestResult testResult, Method method) protected final voidThis method should be called in the setup method of the concrete class.protected final voidThis method should be called in the cleanup method of the concrete class.protected abstract voidsetup()Initializes the test environment state.final voidstateCheck(Method method)
-
Constructor Details
-
TestRetrySupport
public TestRetrySupport()
-
-
Method Details
-
stateCheck
- Throws:
Exception
-
failureCheck
@AfterMethod(alwaysRun=true) public final void failureCheck(org.testng.ITestResult testResult, Method method) -
incrementSetupNumber
protected final void incrementSetupNumber()This method should be called in the setup method of the concrete class. This increases an internal counter and resets the failure state which are used to determine whether cleanup is needed before a test method is called. -
markCurrentSetupNumberCleaned
protected final void markCurrentSetupNumberCleaned()This method should be called in the cleanup method of the concrete class. -
setup
Initializes the test environment state. The implementation of this method must call incrementSetupNumber method.- Throws:
Exception
-
cleanup
Cleans up the state of the environment. The implementation of this method must call the markCurrentSetupNumberCleaned method.- Throws:
Exception
-