assertNotEquals() method
This lesson demonstrates how to use assertNotEquals() method in JUnit 5 to assert test conditions.
We'll cover the following...
assertNotEquals() method
Assertions API provide static assertNotEquals() method. This method helps us in validating that actual and expected values are not equal. This method uses equals() to assert the in-equality of actual and expected value.
- If the actual value is
not equalto expected value then the test case will pass. - If the actual value is
equalto expected value then the test case will fail.
There are basically three useful overloaded methods for assertNotEquals:-
public static void assertNotEquals(Object expected, Object actual)public static void assertNotEquals(Object expected, Object actual, String message)public static void assertNotEquals(Object expected, Object actual, Supplier<String> messageSupplier)
-
assertNotEquals(Object expected, Object actual)- It assert whether expected and actual value arenotequal. -
assertNotEquals(Object expected, Object actual, String message)- It asserts whether expected and actual value arenotequal. In case, if the expected value isequalto actual value then the test case will fail with the provided message. -
assertNotEquals(Object expected, Object actual, Supplier<String> messageSupplier)...