Code coverage is a measurement of percentage of instructions of code being executed while the automated tests are running.
A piece of code with high code coverage implies that the code has been thoroughly unit tested and has a lower chance of containing bugs than code with a low code coverage. You should concentrate on writing meaningful (business logic) unit tests and not on having 100 percent coverage because it's easy to cheat and have 100 percent coverage with completely useless tests.
Numerous metrics can be used to measure the code coverage. The following are the ones that are widely used:
The following Java code will elucidate the metrics.
An absSum
method takes two integer arguments...