...

/

Assertions: assertEquals() and assertNotEquals()

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.

It has many overloaded methods for different primitive types and objects. For example, for the int primitive type, there are three different overloaded methods:

Press + to interact
assertEquals(int expected, int actual)
assertEquals(int expected, int actual, String message)
assertEquals(int expected, int actual, Supplier messageSupplier)
  • The assertEquals(int expected, int actual) method is the simplest form that accepts two int values for the check.
  • The
...