Package org.apache.pulsar.tests
Class MockitoCleanupListener
java.lang.Object
org.apache.pulsar.tests.MockitoCleanupListener
- All Implemented Interfaces:
org.testng.IClassListener,org.testng.ITestListener,org.testng.ITestNGListener
Cleanup Mockito's Thread Local state that leaks memory
Mockito.reset method should be called at the end of a test in the same thread where the methods were
mocked/stubbed. There are some tests which mock methods in the ForkJoinPool thread and these leak memory.
This listener doesn't support parallel execution at TestNG level. This is not thread safe.
Separate forks
testForkCount > 1 controlled with Maven Surefire is the recommended solution
for parallel test execution and that is fine.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonBeforeClass(org.testng.ITestClass testClass) protected voidonBetweenTestClasses(Class<?> endedTestClass, Class<?> startedTestClass) Call back hook for adding logic when test execution moves from test class to another.voidonFinish(org.testng.ITestContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.testng.IClassListener
onAfterClassMethods inherited from interface org.testng.ITestListener
onStart, onTestFailedButWithinSuccessPercentage, onTestFailedWithTimeout, onTestFailure, onTestSkipped, onTestStart, onTestSuccess
-
Constructor Details
-
MockitoCleanupListener
public MockitoCleanupListener()
-
-
Method Details
-
onBetweenTestClasses
Call back hook for adding logic when test execution moves from test class to another.- Parameters:
endedTestClass- the test class which has finished execution. null if the started test class is the firststartedTestClass- the test class which has started execution. null if the ended test class is the last
-
onBeforeClass
public void onBeforeClass(org.testng.ITestClass testClass) - Specified by:
onBeforeClassin interfaceorg.testng.IClassListener
-
onFinish
public void onFinish(org.testng.ITestContext context) - Specified by:
onFinishin interfaceorg.testng.ITestListener
-