How to check exception in JUnit refers to the process of verifying that an expected exception is thrown during the execution of a JUnit test.
In JUnit, the assertThrows() method is used to check for exceptions. The assertThrows() method takes two arguments: the expected exception type, and a lambda expression that represents the code that is expected to throw the exception. If the code does not throw the expected exception, the test will fail.