In software testing, code coverage and test coverage are important metrics. This article explains what each term means, and why they are necessary.
Code Coverage
Code coverage is performed to verify the extent to which the code has been executed. Code coverage scripts generate a report that details how much of the application code has been executed. This is a white-box testing technique.
Advantages of Code Coverage
- Helps developers gauge the nature and health of their code.
- One can introduce their own test cases to establish robust coverage.
- Allows easy removal of dead code, thus improving the efficiency of the entire code base.
Test Coverage
Unlike code coverage, test coverage is a black-box testing technique. It monitors the number of tests that have been executed. The test coverage report provides information about parts of the software where test coverage is being implemented.
Advantages of Test Coverage
- Reports on portions of the codebase not covered by necessary test cases.
- Helps detect areas of test cases that are useless for the current project.
- Helps developers create additional test cases as required to ensure test coverage is maximum.
Understanding code coverage and test coverage are necessary for software architects. These concepts help to clean, strengthen and refine code so that the resulting application is of best quality.