- Type Parameters:
T- The type of the singleton being mocked.
- All Superinterfaces:
AutoCloseable,ScopedMock
Represents an active thread-local mock of a singleton instance. The mocking only affects the thread
on which
Mockito.mockSingleton(Object) was called, and the instance only behaves as a mock on that thread.
The singleton mock is released when this object's ScopedMock.close() method is invoked. If this object is never closed,
the mock will remain active on the initiating thread. It is therefore recommended to create this object within a
try-with-resources statement.
Stubbing and verification on the instance can be done using the standard Mockito APIs.
- See Also:
-
Method Summary
Methods inherited from interface org.mockito.ScopedMock
close, closeOnDemand, isClosed
-
Method Details
-
getInstance
T getInstance()Returns the mocked singleton instance.
-