In JUnit 5, how do you assert an exception?
To construct test code that is anticipated to generate an exception in JUnit 5, we need utilise Assertions. assertThrows (). The test code in the above test is intended to throw an exception of type ApplicationException or a subtype of it.
It is worth noting that in JUnit 4, we had to use @Test(expected = NullPointerException).