Last active
April 17, 2022 13:39
-
-
Save weikangchia/52536f25f55f04de4b5ffcdc63f9ecad to your computer and use it in GitHub Desktop.
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
import org.junit.jupiter.api.Test; | |
import java.time.Duration; | |
import static org.junit.jupiter.api.Assertions.assertThrows; | |
import static org.junit.jupiter.api.Assertions.assertTimeout; | |
class JUnit5Test { | |
@Test | |
void shouldThrowRuntimeException() { | |
assertThrows(RuntimeException.class, () -> { | |
throw new RuntimeException("Exception met"); | |
}); | |
} | |
@Test | |
void shouldTimeoutAfter1Milliseconds() { | |
assertTimeout(Duration.ofMillis(1L), () -> Thread.sleep(500)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment