Junior — Middle
What is meant by code coverage in testing?
sobes.tech AI
Answer from AI
Code coverage is a testing metric that shows which parts of the source code have been executed during tests. It helps assess the completeness of testing and identify code areas that are not tested.
There are several types of coverage:
- Line coverage — how many lines of code were executed.
- Branch coverage — which logical branches (e.g., in if-else statements) were taken.
- Condition coverage — how thoroughly logical conditions are tested.
Example: if you have a method with a condition, and tests only check one branch, branch coverage will be incomplete.
In Java, tools like JaCoCo are often used to measure coverage, integrating with the build process and providing coverage reports.