Introduction
We check exception messages to make sure the error is exactly what we expect. This helps catch bugs and confirm the program handles problems correctly.
When testing that a method throws an error for bad input.
When verifying the error message is clear and helpful to users.
When ensuring the program stops at the right place during failures.
When debugging to confirm the cause of a failure.
When writing tests for code that should prevent invalid actions.