Guidelines for Testing Techniques and Test Measurement
B.6 Statement Testing and Coverage
Introduction
This structural test technique is based
upon the decomposition of the component into constituent statements.
Example
The
two principal questions to answer are:
- what is a statement?
- which statements are executable?
In
general a statement should be an atomic action, that is a statement should be
executed completely or not at all. For
instance:
IF
a THEN b ENDIF
is considered as more than one statement
because b may or may not be executed
depending upon the condition a. The definition of statement used for statement testing need not be the one used in
the language definition.
We
would expect statements which are associated with machine code to be regarded
as executable. For instance, we would
expect all of the following to be regarded as executable:
- assignments;
- loops and selections;
- procedure and function calls;
- variable declarations with explicit
initialisations;
- dynamic allocation of variable storage on a
heap.
However, most other variable
declarations can be regarded as non executable.
Consider,
the following C code:
a;
if (b) {
c;
}
d;
Any test case with b TRUE will achieve
full statement coverage. Note that full
statement coverage can be achieved without exercising with b FALSE.