Mockito 3 Answere

Mockito is based on mocks and stubs, stubs are preconfigured values of preconfigured requests, but if the request is not already predefined, in that case, we have a nice mock feature, which will return null instead of throwing an exception. Mockito provides us an Answers interface and Answer enum which helps us modify this behavior ie response of unstubbed mocks.

Answers interface is reponse and Answer enum is setting the response.

Answer enum provides below values.

  • RETURNS_DEFAULTS
  • RETURNS_SMART_NULLS
  • RETURNS_MOCKS
  • RETURNS_DEEP_STUBS
  • CALLS_REAL_METHODS
  • RETURNS_SELF

 

 

follow us on