Assertions: assertNull() and assertNotNull()

Learn about assertNull() and assertNotNull() methods in JUnit 5.

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.

Get hands-on with 1200+ tech skills courses.