* BAEL-88 Testing in Spring Boot * BAEL-88 Integration tests fixed. * BAEL-905 Improvement task for spring boot testing * BAEL-905 Improvement task for spring boot testing * BAEL-926 Upgrade Junit 5 dependencies to use M4
29 lines
531 B
Java
29 lines
531 B
Java
package com.baeldung;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
public class AssertionTest {
|
|
|
|
@Test
|
|
public void testConvertToDoubleThrowException() {
|
|
String age = "eighteen";
|
|
assertThrows(NumberFormatException.class, () -> {
|
|
convertToInt(age);
|
|
});
|
|
|
|
assertThrows(NumberFormatException.class, () -> {
|
|
convertToInt(age);
|
|
});
|
|
}
|
|
|
|
private static Integer convertToInt(String str) {
|
|
if (str == null) {
|
|
return null;
|
|
}
|
|
return Integer.valueOf(str);
|
|
}
|
|
|
|
}
|