Mockito Any() Vs. Isa()

Definition:

  • Misuse of mockito’s matchers classes to type checks

Code Example:

verify(async).execute(any(AddOrganizationAction.class),
  any(AsyncCallback.class));

// wrong pass
verify(async).execute(any(AddPersonToOrganizationAction.class),
  any(AsyncCallback.class));
verify(async).execute(isA(AddOrganizationAction.class),
  any(AsyncCallback.class));

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring