Testing The Internal Monologue

Definition:

  • Where the writer of the test has been so focused on the lines of code in their implementation that they haven’t sought ways to observe the behaviour of the system from the outside.

Code Example:

@Spy
private Service service = new Service( ... );

@Test
public void withInputAItDoesTheThing() {
    service.process("A");
    verify(service).internalCall();
}

@Test
public void withInputBItDoesntDoTheThing() {
    service.process("B");
    verify(service, never()).internalCall();
}

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring