Class StubbedInvocationMatcher

    • Method Detail

      • answer

        public java.lang.Object answer​(InvocationOnMock invocation)
                                throws java.lang.Throwable
        Specified by:
        answer in interface Answer
        Parameters:
        invocation - the invocation on the mock.
        Returns:
        the value to be returned
        Throws:
        java.lang.Throwable - the throwable to be thrown
      • addAnswer

        public void addAnswer​(Answer answer)
      • wasUsed

        public boolean wasUsed()
        Description copied from interface: Stubbing
        Informs if the stubbing was used

        What does it mean 'used stubbing'? Stubbing like when(mock.foo()).thenReturn(true) is considered used when the method mock.foo() is actually invoked during the execution of code under test.

        This method is used internally by Mockito to report and detect unused stubbings. Unused stubbings are dead code and should be deleted to increase clarity of tests (see MockitoHint.

        To understand how this method is useful, see the description at MockingDetails.getStubbings().

        Specified by:
        wasUsed in interface Stubbing