Assertions: assertArrayEquals() and assertIterableEquals()

Let's describe the assertArrayEquals() and assertIterableEquals() methods in JUnit 5.

The assertArrayEquals() method

The assertArrayEquals() method asserts that two given arrays are equal. It supports arrays of type boolean[], char[], byte[], short[], int[], long[], float[], double[], and Object[].

  • If the actual and expected arrays are equal, the test case passes.
  • If the actual and expected arrays are not equal, the test case fails.

Get hands-on with 1400+ tech skills courses.