Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

What is meant by line coverage/ statement coverage/ code coverage? How is it calculated?

Line coverage, statement coverage, code coverage!! Though these three terms sound different, they are one and the same thing. So please don’t get confused between them. Throughout this article we will be discussing this, and we will be using the common term “code coverage” for all three. From the term itself we can make out that it is from the field of software testing and describes the level to which a particular piece of code has been tested, be it of some variable or function. It gives coverage of the extent of the testing of the source code of the software system or application. Code coverage involves the direct inspection of the code and therefore, it would not be wrong to say that it is a form of white box testing.
Code coverage is very much needed to implement a systematic software testing plan. Apart from testing, it is also given preference in the field of critical industries such as avionics and others, with regard to their security and safety. Code coverage like any other aspect of testing follows a certain criteria and those criteria are called coverage criteria. In some cases more than one criterion can be used. We have discussed about them below:
1. Basic coverage criteria: These are further sub divided in to many types:
(a) Statement coverage: It determines whether or not every node in the software program code has been executed or not.
(b) Condition coverage: This one is also called predicated coverage. This type of coverage determines whether or not the all the Boolean expressions in the whole program have been evaluated or not. It is not necessary that everywhere the condition coverage should imply the decision coverage. In Pascal language it is not necessary since there is no short circuiting of the Boolean expressions.
(c) Decision coverage: This coverage criterion is not to be confused with the branch coverage. It determines whether or not every single edge in the program has been executed or not. For example if- else, switch case etc.
(d) Condition and decision coverage: This type of coverage implements both the condition and decision coverage.
(e) Function coverage: This coverage determines whether or not every sub routine and function in the program has been called or not at least once.
There should be certain measures to counter check these coverage criteria. Fault injection method is one of such measures. It is required to ensure that adequate coverage has been provided to each branch and condition pertaining to the code of the exception handling program while carrying out the testing. There are some exceptions like avionics equipments where the modification of the condition and decision coverage is allowed to some extent. Such coverage is often called as “MC/ DC” or “modified condition/ decision coverage”. Avionics are somewhat safety critical and before testing them it is mandatory that the MC/ DC are met. This is done in order to ensure that they get 100 percent coverage. There arise some cases where you need to test all the possible combinations of the conditions in a decision. In such a case “multiple condition coverage” is used. There are various other types of coverage criteria but they are rarely used:
1. Loop coverage: Determines whether or not all the possible loops in a program code have been executed or not at least once.
2. Path coverage: Determines whether or not every path through a given code has been used at least once or not.
3. LCSAJ coverage: Checks for linear code sequence and jump.
4. Entry / exit coverage: Checks for possible calls and returns of the functions.
5. J- J path coverage: Checks for jump to jump paths.

Lessons Learned in Software Testing Software Testing (2nd Edition) Testing Computer Software, 2nd Edition

Some videos from Youtube regarding Code Coverage:

Advanced Software Testing: Code Coverage

Apex Code Testing & Coverage Best Practices

Code Coverage Metrics and How to Use Them Part 1

Code Coverage Metrics and How to Use Them Part 2

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>