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 Strictness
private boolean
private final MockitoLogger
private IdentityHashMap
private final DefaultStubbingLookupListener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
emitWarnings
(MockitoLogger logger, TestFinishedEvent event, Collection<Object> mocks) boolean
void
onMockCreated
(Object mock, MockCreationSettings settings) Mock object was just created.private void
reportUnusedStubs
(TestFinishedEvent event, Collection<Object> mocks) void
Marks listener as dirty, scheduled for cleanup when the next session startsvoid
setStrictness
(Strictness strictness) void
testFinished
(TestFinishedEvent event) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
testFinished
in interfaceMockitoTestListener
-
reportUnusedStubs
-
emitWarnings
private static void emitWarnings(MockitoLogger logger, TestFinishedEvent event, Collection<Object> mocks) -
onMockCreated
Description copied from interface:MockCreationListener
Mock object was just created.- Specified by:
onMockCreated
in interfaceMockCreationListener
- Parameters:
mock
- created mock objectsettings
- the settings used for creation
-
setStrictness
-
isListenerDirty
public boolean isListenerDirty()- Specified by:
isListenerDirty
in interfaceAutoCleanableListener
-
setListenerDirty
public void setListenerDirty()Marks listener as dirty, scheduled for cleanup when the next session starts
-