Challenge - 5 Problems
Coverage Master in CI
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Understanding coverage report output in pytest
What is the output of the following pytest coverage command snippet when run on a module with 3 functions, where 2 functions are tested and 1 is not?
PyTest
pytest --cov=my_module --cov-report=term # Assume my_module has 3 functions: func_a, func_b, func_c # Tests cover func_a and func_b only
Attempts:
2 left
💡 Hint
Think about how coverage percentage is calculated based on tested functions.
✗ Incorrect
Since 2 out of 3 functions are tested, coverage is approximately 66%.
❓ assertion
intermediate2:00remaining
Correct assertion for coverage threshold in pytest
Which assertion correctly fails the test if coverage is below 80% in a pytest coverage report?
PyTest
coverage_percent = 75 # example value from coverage report # Choose the correct assertion
Attempts:
2 left
💡 Hint
Coverage should be at least 80%.
✗ Incorrect
Assertion B correctly checks coverage is 80% or more, failing otherwise.
❓ locator
advanced2:00remaining
Best practice for locating coverage report file in CI
In a CI pipeline, where should the coverage report file be stored for best accessibility and integration?
Attempts:
2 left
💡 Hint
Think about organization and ease of access for CI tools.
✗ Incorrect
Storing reports in a dedicated directory at the project root keeps files organized and accessible.
❓ framework
advanced2:00remaining
Integrating coverage checks in pytest CI pipeline
Which pytest command line option combination ensures tests fail if coverage is below 90% during CI runs?
Attempts:
2 left
💡 Hint
Look for the correct pytest coverage fail threshold option.
✗ Incorrect
The option --cov-fail-under=90 makes pytest fail if coverage is below 90%.
🔧 Debug
expert3:00remaining
Debugging missing coverage data in CI pipeline
In a CI pipeline, coverage reports show 0% coverage despite tests running successfully. What is the most likely cause?
Attempts:
2 left
💡 Hint
Think about how coverage data files are handled in CI.
✗ Incorrect
If coverage data files are overwritten or deleted before report generation, coverage shows 0%.