
One of the three coverage measures that the Coverage API calculates.
Branch coverage reports on whether all paths through control structures have been taken. In general, control structures express branching decisions in the form of boolean expressions, so that branch coverage measures whether such expressions have evaluated to both true and false. But ABAP also has non-conditional branch statements, in which branching is not governed by the evaluation of a boolean expression.
Example: An IF...ELSEIF...ENDIF construct has 100% branch coverage if both the IF and ELSEIF statements have been executed with both true and false results.
Details
The Coverage API statistic reports the percentage of branches in the code under test that were executed at least once.
ABAP distinguishes between conditional, unconditional, and 'switchable' branching statements.
Conditional branching statements each define a true and a false branch. For 100% coverage, each of the conditions of the statement must evaluate to both true and false.
The conditional ABAP branch statements are as follows:
AT in control structures (with ENDAT)
CHECK
DO when used with TIMES
IF and ELSEIF ( ELSE is not counted as a branching statement)
LOOP
ON
PROVIDE
SELECT when used with ENDSELECT
WHEN ( OTHERS is not counted as a branching statement)
WHILE
Unconditional branching statements define only one branch each. CATCH and CLEANUP are the unconditional branch statements in ABAP. If they are executed, their branch coverage is 100%. If not, their branch coverage is 0%.
Switchable branch statements are as follows: ASSERT, ENHANCEMENT, ENHANCEMENT-POINT, and ENHANCEMENT-SECTION. The Coverage API ignores switchable branch statements for purposes of measuring branch code coverage.
In addition, each processing block is considered to contain a default branch defined by the processing block itself. This default branch has a coverage of 100% if the processing block is executed, 0% if the processing block does not run.
You can display the exact coverage of branches in ABAP source code in the graphical display of the Coverage API.
ABAP's branch coverage does not offer the possibility of measuring condition coverage - whether boolean subexpressions in a control statement have evaluated to both true and false. However, in the display of coverage at the source code level, you can display how subexpressions in a branching statement evaluated during a code coverage measurement.
Branch coverage is often considered the most useful commonly available measure of code coverage. A high percentage of branch coverage implies that many execution paths have been taken through the code under test. Further, as a rule a given level of branch coverage provides more comprehensive testing than the same level in statement coverage.
Branch coverage is also known as decision coverage.