JUnit 5 Expected Exception
In JUnit 5, we can use assertThrows to assert an exception is thrown. P.S Tested with JUnit 5.5.2 1. Unchecked Exception 1.1 JUnit example of catching a runtime exception. ExceptionExample1.java package com.mkyong.assertions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class ExceptionExample1 { @Test void test_exception() { Exception exception = assertThrows( ArithmeticException.class, () -> divide(1, 0)); assertEquals("/ …