Recall & Review
beginner
What is a flaky test?
A flaky test is a test that sometimes passes and sometimes fails without any changes in the code. It behaves unpredictably.
Click to reveal answer
beginner
Why is flaky test detection important?
Detecting flaky tests helps keep the test suite reliable. It prevents false failures that waste time and hide real problems.
Click to reveal answer
intermediate
How can pytest help retry flaky tests?
Pytest can use the 'pytest-rerunfailures' plugin to automatically rerun failed tests a set number of times before marking them as failed.
Click to reveal answer
intermediate
Show a simple pytest example to retry a flaky test up to 3 times.
Use the decorator @pytest.mark.flaky(reruns=3) on the test function. This reruns the test up to 3 times if it fails.
Click to reveal answer
advanced
What is a good practice to reduce flaky tests besides retrying?
Fix the root cause of flakiness by improving test isolation, avoiding timing issues, and using mocks or stubs for unstable dependencies.
Click to reveal answer
What does a flaky test do?
✗ Incorrect
A flaky test is unpredictable and can pass or fail randomly.
Which pytest plugin helps retry failed tests?
✗ Incorrect
pytest-rerunfailures reruns failed tests automatically.
How do you specify retry count for flaky tests in pytest?
✗ Incorrect
The @pytest.mark.flaky decorator with reruns sets retry count.
What is NOT a good way to reduce flaky tests?
✗ Incorrect
Ignoring flaky tests does not solve the problem.
If a test fails once but passes on retry, what does it indicate?
✗ Incorrect
Passing on retry suggests the test might be flaky.
Explain what a flaky test is and why it is a problem in software testing.
Think about tests that don't behave the same every time.
You got /4 concepts.
Describe how you can use pytest to detect and retry flaky tests.
Focus on the tools and settings in pytest.
You got /4 concepts.