Answers for "test thrown expected with jupiter spring boot"

0

test thrown expected with jupiter spring boot

@Test
public void whenExceptionThrown_thenAssertionSucceeds() {
    Exception exception = assertThrows(NumberFormatException.class, () -> {
        Integer.parseInt("1a");
    });

    String expectedMessage = "For input string";
    String actualMessage = exception.getMessage();

    assertTrue(actualMessage.contains(expectedMessage));
}
Posted by: Guest on December-29-2020

Code answers related to "test thrown expected with jupiter spring boot"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language