...

/

assertNotEquals() method

assertNotEquals() method

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

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:-

Press + to interact
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)
  1. assertNotEquals(Object expected, Object actual) - It assert whether expected and actual value are not equal.

  2. assertNotEquals(Object expected, Object actual, String message) - It asserts whether expected and actual value are not equal. In case, if the expected value is equal to actual value then the test case will fail with the provided message.

  3. assertNotEquals(Object ...

Access this course and 1400+ top-rated courses and projects.