0
0
PyTesttesting~5 mins

Coverage in CI pipelines in PyTest - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is code coverage in the context of CI pipelines?
Code coverage measures how much of your code is tested by automated tests during CI runs. It helps ensure tests cover important parts of the code.
Click to reveal answer
beginner
Why integrate coverage reports in CI pipelines?
Integrating coverage reports in CI helps catch untested code early, improves code quality, and prevents bugs by enforcing testing standards automatically.
Click to reveal answer
beginner
Which pytest plugin is commonly used to measure coverage?
The pytest-cov plugin is used to measure code coverage when running pytest tests. It generates coverage reports in various formats.
Click to reveal answer
intermediate
How can you fail a CI build if coverage drops below a threshold using pytest?
Use pytest-cov options like --cov-fail-under=80 to fail the build if coverage is below 80%. This enforces minimum coverage standards automatically.
Click to reveal answer
intermediate
What is a common format for coverage reports to integrate with CI tools?
The XML format (coverage.xml) is commonly used because many CI tools and coverage services can read it to display coverage results.
Click to reveal answer
What does code coverage measure in CI pipelines?
AThe percentage of code executed by tests
BThe number of tests written
CThe speed of test execution
DThe number of bugs found
Which pytest plugin helps generate coverage reports?
Apytest-xdist
Bpytest-mock
Cpytest-html
Dpytest-cov
How can you make a CI build fail if coverage is too low?
AUse --max-time option with pytest
BUse --fail-on-error option with pytest
CUse --cov-fail-under option with pytest-cov
DUse --skip-covered option with pytest-cov
Which coverage report format is widely supported by CI tools?
AXML
BTXT
CCSV
DJSON
Why is it important to include coverage in CI pipelines?
ATo speed up the build process
BTo ensure tests cover critical code and maintain quality
CTo reduce the number of tests
DTo avoid writing tests
Explain how to set up pytest coverage reporting in a CI pipeline.
Think about the commands and CI configuration steps.
You got /5 concepts.
    Describe the benefits of enforcing coverage thresholds in CI pipelines.
    Consider quality and team discipline reasons.
    You got /5 concepts.