Skip to content

Instantly share code, notes, and snippets.

@igorstojanovski
Created October 14, 2023 22:03
Show Gist options
  • Save igorstojanovski/ecda08b1bfcd34dec9d898fe114e79e3 to your computer and use it in GitHub Desktop.
Save igorstojanovski/ecda08b1bfcd34dec9d898fe114e79e3 to your computer and use it in GitHub Desktop.
Sample Junit 5 test with a Mockito Extension
@ExtendWith(MockitoExtension.class)
class PersonTest {
@Mock
PinProvider pinProvider;
@Test
public void shouldCreatePersonWithCorrectPin() {
String samplePin = "samplePin";
when(pinProvider.getPin()).thenReturn(samplePin);
Person person = new Person("Star", "Lord", pinProvider);
assertThat(person.getPin()).isEqualTo(samplePin);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment