@Target(value=TYPE) @Retention(value=RUNTIME) @Documented public @interface DoNotMock
When marking a type @DoNotMock
, you should always point to alternative testing
solutions such as standard fakes or other testing utilities.
Mockito enforces @DoNotMock
with the DoNotMockEnforcer
.
If you want to use a custom @DoNotMock
annotation, the DoNotMockEnforcer
will match on annotations with a type ending in "org.mockito.DoNotMock". You can thus place
your custom annotation in com.my.package.org.mockito.DoNotMock
and Mockito will enforce
that types annotated by @com.my.package.org.mockito.DoNotMock
can not be mocked.
@DoNotMock(reason = "Use a real instance instead")
class DoNotMockMe {}
public abstract String reason
This should suggest alternative APIs to use for testing objects of this type.