Last active
July 12, 2022 20:31
-
-
Save kauanmocelin/0965d581e4c01c28df35915e98624d5f to your computer and use it in GitHub Desktop.
Teste de Unidade - Mockar o tempo - LocalDateTime #teste
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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