0

Find out if an object is a mock or spy in Mockito

The need for it

Finding out if an object is a mock or spy in Mockito may not (or never) be part of your usual automated unit tests but in some cases (advanced usage of JUnit/Mockito) you may need to determine its type.

Is Mock or Spy?

Below is a sample code to determine if an object is mock or spy in Mockito.

Download the Codes

https://github.com/Turreta/mockito-spy-or-mock-example

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert