Mockito

Mockito is a Java library that creates mocks: fake objects whose responses you program with when(...).thenReturn(...) and whose calls you verify with verify. It integrates with JUnit, notably with @Mock and @InjectMocks, to test a class without its real dependencies.

Example

when(repo.trouver(1)).thenReturn(Optional.of(client));
verify(repo).trouver(1);

Related concepts

The whole glossary