0
0
PyTesttesting~5 mins

pytest-cov setup - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is pytest-cov used for?
pytest-cov is a plugin for pytest that measures code coverage during test runs. It shows which parts of your code were tested and which were not.
Click to reveal answer
beginner
How do you install pytest-cov?
You install pytest-cov using pip with the command: pip install pytest-cov.
Click to reveal answer
beginner
How do you run pytest with coverage reporting?
Run tests with coverage by using: pytest --cov=your_package_name. Replace your_package_name with the folder or module you want to check coverage for.
Click to reveal answer
intermediate
What does the option --cov-report=term do?
It shows the coverage report directly in the terminal after tests finish, so you can quickly see which lines were covered.
Click to reveal answer
intermediate
How can you generate an HTML coverage report with pytest-cov?
Use the command: pytest --cov=your_package_name --cov-report=html. This creates a folder named htmlcov with a detailed, easy-to-read coverage report you can open in a browser.
Click to reveal answer
Which command installs pytest-cov?
Apytest --install-cov
Bpip install pytest-cov
Cpip install coverage
Dpip install pytest
What does pytest --cov=myapp do?
ARuns tests only for the 'myapp' package
BGenerates an HTML report only
CRuns tests and measures coverage for the 'myapp' package
DInstalls coverage for 'myapp'
How do you see coverage results in the terminal?
ACoverage is shown by default
BAdd <code>--show-coverage</code> option
CAdd <code>--coverage-output=console</code> option
DAdd <code>--cov-report=term</code> option
Where does pytest-cov put the HTML report by default?
AIn the <code>htmlcov</code> folder
BIn the root folder
CIn the <code>coverage</code> folder
DIn the <code>reports</code> folder
What must you specify to measure coverage for a specific package?
AThe package name after <code>--cov=</code>
BThe test file name
CThe Python version
DThe pytest version
Explain how to set up pytest-cov to measure and report test coverage for a Python project.
Think about installation, running tests, and viewing coverage.
You got /4 concepts.
    Describe the benefits of using pytest-cov in your testing workflow.
    Consider how coverage helps improve tests.
    You got /4 concepts.