Introduction
We use assertThrows to check if a piece of code correctly throws an error when something goes wrong. This helps us catch mistakes early.
When you want to test that a method throws an exception for invalid input.
When you want to make sure your code handles errors properly.
When you want to confirm that a specific error type is thrown in a certain situation.