Recall & Review
beginner
What is exception testing in software testing?
Exception testing is a technique where tests are designed to check how software behaves when unexpected or error conditions occur, such as invalid inputs or system failures.
Click to reveal answer
beginner
Why is exception testing important for error handling?
Exception testing ensures that the software correctly detects errors and responds properly, such as by throwing the right exceptions or showing meaningful messages, which helps prevent crashes and improves reliability.
Click to reveal answer
intermediate
How does JUnit support exception testing?
JUnit allows you to write tests that expect exceptions using annotations like @Test(expected = Exception.class) or the assertThrows method, making it easy to verify that error handling works as intended.
Click to reveal answer
beginner
What happens if exception testing fails?
If exception testing fails, it means the software did not handle the error as expected, which could lead to crashes, incorrect behavior, or security issues in real use.
Click to reveal answer
intermediate
Give an example of exception testing in JUnit.
Example: Using assertThrows to check if a method throws IllegalArgumentException when given a bad input.<br>
assertThrows(IllegalArgumentException.class, () -> { myMethod(null); });Click to reveal answer
What is the main goal of exception testing?
✗ Incorrect
Exception testing focuses on verifying that the software properly handles error conditions.
Which JUnit feature helps test if a method throws an exception?
✗ Incorrect
The @Test annotation with expected parameter allows testing if a specific exception is thrown.
What does it mean if an exception test passes?
✗ Incorrect
Passing exception tests means the software threw the expected exception, showing proper error handling.
Why should exception testing be part of QA?
✗ Incorrect
Exception testing helps confirm that software behaves reliably when errors happen.
Which method in JUnit 5 is used to assert exceptions?
✗ Incorrect
assertThrows is used in JUnit 5 to check if a block of code throws a specific exception.
Explain why exception testing is essential for validating error handling in software.
Think about what happens when software faces unexpected problems.
You got /4 concepts.
Describe how you would write a JUnit test to check that a method throws an exception for invalid input.
Focus on JUnit syntax for exception testing.
You got /3 concepts.