assertNotNull() method
This lesson demonstrates how to use assertNotNull() method in JUnit 5 to assert test conditions.
We'll cover the following...
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:-
public static void assertNotNull(Object actual)public static void assertNotNull(Object actual, String message)public static void assertNotNull(Object actual, Supplier<String> messageSupplier)
-
assertNotNull(Object actual)
- It assert whether actual value is not null. -
assertNotNull(Object actual, String message)
- It assert whether actual value is not null. In case, if the actual value is null then test case will fail with the provided message. -
assertNotNull(Object actual, Supplier<String> messageSupplier)
- It assert whether actual value is not null. In case, if the actual value is null then test case will fail with the ...