Interface StubbingLookupListener


  • public interface StubbingLookupListener
    When a method is called on a mock object Mockito looks up any stubbings recorded on that mock. This listener gets notified on stubbing lookup. Register listener via MockSettings.stubbingLookupListeners(StubbingLookupListener...). This API is used by Mockito to implement PotentialStubbingProblem (part of Mockito Strictness).

    Details: When method is called on the mock object, Mockito looks for any answer (stubbing) declared on that mock. If the stubbed answer is found, that answer is then invoked (value returned, thrown exception, etc.). If the answer is not found (e.g. that invocation was not stubbed on the mock), mock's default answer is used. This listener implementation is notified when Mockito attempts to find an answer for invocation on a mock.

    The listeners can be accessed via MockCreationSettings.getStubbingLookupListeners().

    Since:
    2.24.6
    • Method Detail

      • onStubbingLookup

        void onStubbingLookup​(StubbingLookupEvent stubbingLookupEvent)
        Called by the framework when Mockito looked up an answer for invocation on a mock. For details, see StubbingLookupListener.
        Parameters:
        stubbingLookupEvent - - Information about the looked up stubbing
        Since:
        2.24.6