junit5 test expected exception code example
Example 1: junit 5 expected exception
@Test
void testExpectedException() {
Assertions.assertThrows(NumberFormatException.class, () -> {
Integer.parseInt("One");
});
}
Example 2: expected exception junit
@Test(expected = SomeException.class)
public void testName() {
//some code
}