Recall & Review
beginner
What is the main idea behind the 'single assertion per test' approach?
It means each test method should check only one condition or behavior to keep tests simple and focused.
Click to reveal answer
intermediate
Why might some developers prefer multiple assertions in one test?
Because it can reduce the number of test methods and group related checks, making tests shorter.
Click to reveal answer
beginner
What is a downside of having multiple assertions in a single test?
If one assertion fails, the rest are skipped, so you might miss other problems in the same test run.
Click to reveal answer
beginner
How does the single assertion rule help with debugging test failures?
It makes it clear exactly what failed, so you can fix problems faster without guessing which check caused the failure.
Click to reveal answer
intermediate
Can you combine multiple related checks in one test without violating the single assertion idea?
Yes, by using one assertion that checks a combined condition or by splitting tests logically to keep clarity.
Click to reveal answer
What is a key benefit of using a single assertion per test?
✗ Incorrect
Using one assertion per test helps quickly find the exact failure cause.
What happens if a test with multiple assertions fails on the first assertion?
✗ Incorrect
JUnit stops running the test after the first failed assertion.
Which is a reason to use multiple assertions in one test?
✗ Incorrect
Grouping related checks can make tests shorter and organized.
How can you keep tests clear while testing multiple conditions?
✗ Incorrect
One assertion per test keeps tests focused and easy to understand.
What is a practical compromise in the single assertion debate?
✗ Incorrect
You can group related checks but keep unrelated ones separate for clarity.
Explain the pros and cons of using a single assertion per test in JUnit.
Think about test clarity and failure detection.
You got /5 concepts.
Describe how you would decide when to use single or multiple assertions in a test.
Focus on clarity and maintenance.
You got /4 concepts.