Class ThrowsMethodExceptionAnswer

  • All Implemented Interfaces:
    Serializable, org.mockito.stubbing.Answer<Object>

    @Beta
    public final class ThrowsMethodExceptionAnswer
    extends Object
    implements org.mockito.stubbing.Answer<Object>, Serializable
    Mockito Answer which for un-stubbed methods throws an UnstubbedMethodException (instead of Mockito's default of returning null).

    Usage:

     import static ...testutils.mockito.MoreAnswers.exception;
    
     Mockito.mock(YourInterface.class, exception())
     
    Author:
    Michael Vorburger
    See Also:
    Mockito.mock(Class, Answer), ThrowsException, Serialized Form
    • Method Detail

      • answer

        public Void answer​(org.mockito.invocation.InvocationOnMock invocation)
        Specified by:
        answer in interface org.mockito.stubbing.Answer<Object>