Assertions: assertNull() and assertNotNull()
Learn about assertNull() and assertNotNull() methods in JUnit 5.
We'll cover the following...
We'll cover the following...
The assertNull() method
The assertNull() method asserts that the given Object is null.
- If the actual value is
null, the test case passes. - If the actual value is
not null, the test case fails.
It has three different overloaded methods:
- The
assertNull(Object actual)method is the simplest form that only accepts a singleObjectto check. - For the
assertNull(Object actual, String message)method, when theObjectisn’t