Test Coverage is one of the evaluate metrics for quality testing degree. It is a useful tool for finding untested parts and active parts of the source-code.
The higher required level of test coverage, the more tests will be selected for testing test requirements or executable code.
Testing with 100% coverage is almost impossible. Thoughtful and well done testing could give a coverage percentage in the upper 80s. That’s why for test set development you should use special tools or test design techniques.
There are two methods widely applied for evaluate the quality of testing:
- Requirement coverage is the number of requirements passed in proportion to total number of requirements. This is the dimensions to Unit Testing using traceability matrix.
- Code Coverage is also a measure used to describe the degree to which the source code of a program has been tested by tracking untested pieces in the testing process.
The difference between these two methods is in their missions: Requirement coverage checks the correspondence between set test and product requirements, while the Code coverage focused on the full testing the source code.
However, we want to show in succeeding text how exactly you can distinguish these two methods.
You can calculate test coverage as for requirements using following formula:
Tcov: is test coverage;
Lcov: is requirement number that is checked by test code cases;
Ltotal: is total amount of requirements.
You need to analyze product requirements and divide it into paragraphs.
To optimize test coverage it is rather to use typical test design techniques.
Next formula defines the test coverage degree as for executed software code:
Tcov: test coverage
Ltc: number of covered by test code lines
Lcode: total amount of code lines.
You can find a lot of interesting tools like Clover, that allow you to find out which of links have being entered during the test process. So you can enhance the cover by addition of new tests for particular case and to exclude double tests.
So, the value of coverage analysis is that it helps to find which bits of your code are not tested, that could improve the quality of testing process.