Bumbling Assertions

Definition:

  • Where there was a more articulate assertion available, but we chose a less sophisticated one and kind of got the message across. E.g. testing exceptions the hard way, or using equality check on list size, rather than a list size assertion.

Code Example:

Optional<Foo> result = service.getFoos(123);
assertNotNull(result);
assertThat(result).isNotEmpty();
assertThat(result.getBar()).isNotNull();
assertThat(result.getBar()).hasSize(1);
assertThat(result.getBar().get(0)).isEqualTo("buzz");

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring