Package org.mockito.internal.junit
Class UniversalTestListener
java.lang.Object
org.mockito.internal.junit.UniversalTestListener
- All Implemented Interfaces:
MockitoTestListener,AutoCleanableListener,MockCreationListener,MockitoListener
public class UniversalTestListener
extends Object
implements MockitoTestListener, AutoCleanableListener
Universal test listener that behaves accordingly to current setting of strictness.
Will come handy when we offer tweaking strictness at the method level with annotation.
Should be relatively easy to improve and offer tweaking strictness per mock.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Strictnessprivate booleanprivate final MockitoLoggerprivate IdentityHashMapprivate final DefaultStubbingLookupListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidemitWarnings(MockitoLogger logger, TestFinishedEvent event, Collection<Object> mocks) booleanvoidonMockCreated(Object mock, MockCreationSettings settings) Mock object was just created.private voidreportUnusedStubs(TestFinishedEvent event, Collection<Object> mocks) voidMarks listener as dirty, scheduled for cleanup when the next session startsvoidsetStrictness(Strictness strictness) voidtestFinished(TestFinishedEvent event) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.mockito.listeners.MockCreationListener
onStaticMockCreated
-
Field Details
-
currentStrictness
-
logger
-
mocks
-
stubbingLookupListener
-
listenerDirty
private boolean listenerDirty
-
-
Constructor Details
-
UniversalTestListener
-
-
Method Details
-
testFinished
- Specified by:
testFinishedin interfaceMockitoTestListener
-
reportUnusedStubs
-
emitWarnings
private static void emitWarnings(MockitoLogger logger, TestFinishedEvent event, Collection<Object> mocks) -
onMockCreated
Description copied from interface:MockCreationListenerMock object was just created.- Specified by:
onMockCreatedin interfaceMockCreationListener- Parameters:
mock- created mock objectsettings- the settings used for creation
-
setStrictness
-
isListenerDirty
public boolean isListenerDirty()- Specified by:
isListenerDirtyin interfaceAutoCleanableListener
-
setListenerDirty
public void setListenerDirty()Marks listener as dirty, scheduled for cleanup when the next session starts
-