Search code examples
javajunitjunit5

Why aren't my `assertEquals` statements all displaying something?


The following is a snippet from my JUnit5 test class.

@Test
@DisplayName("This is just a simple JUnit 5 test")
void testSimple() {
    assertEquals(2, 3, "this is the 1st assertEquals");
    assertEquals(4, 5, "this is the 2nd assertEquals");
    assertEquals(5, 6, "this is the 3rd asswerEquals");
}

However, when I run this, I only manage to get the first assert statement to show the message. As all of them clearly fail, shouldn't they all be showing their respective messages?


Solution

  • As highlighted in the comments section above, an exception is thrown if assertEquals fails. This prevents any following statements from being reached.