Skip to content

Instantly share code, notes, and snippets.

@kauanmocelin
Last active July 12, 2022 20:31
Show Gist options
  • Save kauanmocelin/0965d581e4c01c28df35915e98624d5f to your computer and use it in GitHub Desktop.
Save kauanmocelin/0965d581e4c01c28df35915e98624d5f to your computer and use it in GitHub Desktop.
Teste de Unidade - Mockar o tempo - LocalDateTime #teste
@Test
void mockTime() {
LocalDateTime fixed = LocalDateTime.parse("2021-09-29T23:00:00");
try (MockedStatic<LocalDateTime> b = Mockito.mockStatic(LocalDateTime.class)) {
b.when(LocalDateTime::now).thenReturn(fixed);
System.out.println(LocalDateTime.now());
}_
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment