assertNotNull() method

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

assertNotNull() method

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

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

There are basically three overloaded methods for assertNotNull:-

Get hands-on with 1200+ tech skills courses.