Assertions: assertEquals() and assertNotEquals()

Learn about the assertEquals() and assertNotEquals() methods in JUnit 5.

The assertEquals() method

The assertEquals() method asserts that two given values are equal.

  • If the actual value is equal to the expected value, the test case passes.
  • If the actual value isn’t equal to the expected value, the test case fails.

Get hands-on with 1200+ tech skills courses.