assertNull() method

This lesson demonstrates how to use assertNull() method in JUnit 5 to assert test conditions.

assertNull() method

Assertions API provide static assertNull() method. This method helps us in validating that the particular object is null. This method takes an actual value and checks whether it is null or not.

  • If the actual value is null then test case will pass.
  • If the actual value is not null then test case will fail.

There are basically three overloaded methods for assertNull which are described below:-

Get hands-on with 1200+ tech skills courses.