assertEquals() method

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

assertEquals() method

Assertions API provide static assertEquals() method. This method helps us in validating that actual and expected values are equal. This method uses equals() to assert the equality of actual and expected value.

  • If the actual value is equal to expected value then the test case will pass.
  • If the actual value is not equal to expected value then the test case will fail.

There are basically three useful overloaded methods for assertEquals:-

Get hands-on with 1200+ tech skills courses.