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 equal
to expected value then the test case will pass. - If the actual value is
equal
to 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 arenot
equal. -
assertNotEquals(Object expected, Object actual, String message)
- It asserts whether expected and actual value arenot
equal. In case, if the expected value isequal
to actual value then the test case will fail with the provided message. -
assertNotEquals(Object
...