assertNull() method
This lesson demonstrates how to use assertNull() method in JUnit 5 to assert test conditions.
We'll cover the following...
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:-
Press + to interact
public static void assertNull(Object actual)public static void assertNull(Object actual, String message)public static void assertNull(Object actual, Supplier<String> messageSupplier)
-
assertNull(Object actual)
- It asserts whether actual value is null or not. -
assertNull(Object actual, String message)
- It asserts whether actual value is null or not. In case, if the actual value is not null then the test case will fail with a provided message. -
assertNull(Object actual, Supplier<String> messageSupplier)
- It assert whether actual value is null or ...
Access this course and 1400+ top-rated courses and projects.