Recall & Review
beginner
What does 'single responsibility per test' mean in software testing?
It means each test should check only one specific behavior or feature. This makes tests easier to understand and fix when they fail.
Click to reveal answer
beginner
Why is it better to have one assertion per test?
Having one assertion per test helps quickly find what went wrong. If a test fails, you know exactly which part of the code has a problem.
Click to reveal answer
intermediate
Example of a bad test violating single responsibility principle:
A test that checks if a user can log in and also if the user profile loads correctly. These should be two separate tests.
Click to reveal answer
intermediate
How does single responsibility per test help with test maintenance?
When tests focus on one thing, it's easier to update or fix them if the related feature changes. It reduces confusion and errors.
Click to reveal answer
beginner
In pytest, how can you organize tests to follow single responsibility?
Write small test functions each testing one behavior. Use clear names describing what each test checks.
Click to reveal answer
What is the main benefit of having a single responsibility per test?
✗ Incorrect
When each test checks only one thing, failures point directly to the problem.
Which of these violates the single responsibility principle in testing?
✗ Incorrect
Testing multiple features in one test makes it harder to identify issues.
In pytest, how should you name tests to support single responsibility?
✗ Incorrect
Descriptive names clarify what each test checks, supporting single responsibility.
What happens if a test has multiple responsibilities and fails?
✗ Incorrect
Multiple responsibilities make it unclear which part caused failure.
Which practice helps maintain tests better?
✗ Incorrect
One test per behavior keeps tests clear and easier to update.
Explain why single responsibility per test is important and how it improves test quality.
Think about how you find problems faster when tests focus on one thing.
You got /4 concepts.
Describe how you would write pytest functions to follow the single responsibility principle.
Imagine each test as a small story about one feature.
You got /4 concepts.