Is Mockito Working Fine?

Definition:

  • When the mock framerwork is tested intead of the SUT

Code Example:

@Test
public void testFormUpdate() {
  // given
  Form f = Mockito.mock(Form.class);
  Mockito.when(f.isUpdateAllowed()).thenReturn(true);
  // when
  boolean result = f.isUpdateAllowed();
  // then
  assertTrue(result);
}

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring