|
19 | 19 |
|
20 | 20 | import static org.junit.jupiter.api.Assertions.assertThrows; |
21 | 21 |
|
| 22 | +import org.junit.jupiter.api.Assertions; |
22 | 23 | import org.junit.jupiter.api.function.Executable; |
23 | 24 |
|
24 | 25 | /** |
25 | 26 | * Specialized APIs to complement {@link org.junit.jupiter.api.Assertions}. |
26 | 27 | */ |
27 | 28 | public class LangAssertions { |
28 | 29 |
|
| 30 | + /** |
| 31 | + * Asserts that execution of the given {@code executable} throws a {@link NullPointerException}. |
| 32 | + * |
| 33 | + * <p> |
| 34 | + * The assertion passes if the thrown exception type is the same as {@link NullPointerException} or a subtype. To check for the exact thrown type |
| 35 | + * use {@link Assertions#assertThrowsExactly(Class, Executable) assertThrowsExactly}. If no exception is thrown, or if an exception of a different type is |
| 36 | + * thrown, this method fails. |
| 37 | + * </p> |
| 38 | + * |
| 39 | + * @param executable What to test. |
| 40 | + * @return The thrown NullPointerException. |
| 41 | + * @see Assertions#assertThrowsExactly(Class, Executable) |
| 42 | + */ |
29 | 43 | public static NullPointerException assertNullPointerException(final Executable executable) { |
30 | 44 | return assertThrows(NullPointerException.class, executable); |
31 | 45 | } |
32 | 46 |
|
| 47 | + /** |
| 48 | + * Asserts that execution of the given {@code executable} throws a {@link NullPointerException}. |
| 49 | + * |
| 50 | + * <p> |
| 51 | + * The assertion passes if the thrown exception type is the same as {@link NullPointerException} or a subtype. To check for the exact thrown type |
| 52 | + * use {@link Assertions#assertThrowsExactly(Class, Executable) assertThrowsExactly}. If no exception is thrown, or if an exception of a different type is |
| 53 | + * thrown, this method fails. |
| 54 | + * </p> |
| 55 | + * |
| 56 | + * @param executable What to test. |
| 57 | + * @param message The message for the failure if the executable doesn't throw a NullPointerException. |
| 58 | + * @return The thrown NullPointerException. |
| 59 | + * @see Assertions#assertThrowsExactly(Class, Executable) |
| 60 | + */ |
33 | 61 | public static NullPointerException assertNullPointerException(final Executable executable, final String message) { |
34 | 62 | return assertThrows(NullPointerException.class, executable, message); |
35 | 63 | } |
|
0 commit comments