Types of Coverage?

There are many types of test coverage. Test coverage can be used in any level of the testing. Test coverage can be measured based on a number of different structural elements in a system or component. Coverage can be measured at component testing level, integration-testing level or at system- or acceptance-testing levels. For example, at system or acceptance level, the coverage items may be requirements, menu options, screens, or typical business transactions. At integration level, we could measure coverage of interfaces or specific interactions that have been tested.

The coverage measures for specification-based techniques would apply at whichever test level the technique has been used (e.g. system or component level).

Measure coverage for Specification-based Technique

  • EP: percentage of equivalence partitions exercised (we could measure valid and invalid partition coverage separately if this makes sense);
  • BVA: percentage of boundaries exercised (we could also separate valid and invalid boundaries if we wished);
  • Decision tables: percentage of business rules or decision table columns tested;
  • State transition testing. See below...

For State transition - possible coverage measures:

  • Percentage of states visited
  • Percentage of (valid) transitions exercised (this is known as Chow’s 0- switch coverage)
  • Percentage of pairs of valid transitions exercised (‘transition pairs’ or
  • Chow’s 1-switch coverage) – and longer series of transitions, such as transition triples, quadruples, etc.
  • Percentage of invalid transitions exercised (from the state table).

The different types of coverage are:

1. What is Statement coverage?

  • The statement coverage is also known as line coverage or segment coverage.
  • The statement coverage covers only the true conditions.
  • Through statement coverage we can identify the statements executed and where the code is not executed because of blockage.
  • In this process each and every line of code needs to be checked and executed.

Advantage of statement coverage:

  • It verifies what the written code is expected to do and not to do
  • It measures the quality of code written
  • It checks the flow of different paths in the program and it also ensure that whether those path are tested or not.

Disadvantage of statement coverage:

  • It cannot test the false conditions.
  • It does not report that whether the loop reaches its termination condition.
  • It does not understand the logical operators.

The statement coverage can be calculated as below:

2. What is Branch Coverage or Decision Coverage?

  • Branch coverage is also known as Decision coverage or all-edges coverage.
  • It covers both the true and false conditions unlikely the statement coverage.
  • A branch is the outcome of a decision, so branch coverage simply measures which decision outcomes have been tested. This sounds great because it takes a more in-depth view of the source code than simple statement coverage.
  • A decision is an IF statement, a loop control statement (e.g. DO-WHILE or REPEAT-UNTIL), or a CASE statement, where there are two or more outcomes from the statement. With an IF statement, the exit can either be TRUE or FALSE, depending on the value of the logical condition that comes after IF.

Advantages of decision coverage:

  • To validate that all the branches in the code are reached
  • To ensure that no branches lead to any abnormality of the program’s operation
  • It eliminate problems that occur with statement coverage testing

Disadvantages of decision coverage:

  • This metric ignores branches within boolean expressions which occur due to short-circuit operators.

3. What is Condition coverage?

  • This is closely related to decision coverage but has better sensitivity to the control flow.
  • However, full condition coverage does not guarantee full decision coverage.
  • Condition coverage reports the true or false outcome of each condition.
  • Condition coverage measures the conditions independently of each other.