Junior — Middle
How is the test coverage level determined?
sobes.tech AI
Answer from AI
The test coverage level is defined as the percentage of code that was executed during test runs. It is usually measured using coverage tools that analyze which lines, branches, or functions were called.
In Python, popular tools include coverage.py and pytest-cov. They show:
- line coverage
- function coverage
- branch coverage
For example, to check coverage with coverage.py:
coverage run -m pytest
coverage report
The higher the coverage percentage, the more code has been tested, but it is important to remember that 100% coverage does not guarantee the absence of errors.