Skip to main content

Description of the method

Decision testing belongs to the family of logical coverages, as it's concerned with the values of logical predicates in deciding instructions. The other name for the technique comes from there: predicate coverage. A decision is simply a logical statement that can take the value of true or false.


Decision result – an output of a decision, determining the branch to follow


Examples of deciding instructions:

  • if conditional instruction: if (decision) then …;

  • while instruction condition: while (decision) do …;

  • do-while instruction condition: dowhile (decision);

  • switch-case instruction;

  • for loop instruction condition: for (initialization; decision; incrementation) do condition …;

Decision testing requires that every instruction in the program takes the logical value of true and false at least once each. For example if the following instruction exists in a program:


if (x > 0 and y == 0) then …


then the (x > 0 ∧ y = 0) condition must be true at least once and must be false at least once. The result can be forced to be true by for example assuming that: x = 1 and y = 0, and to be false by having: x = 1 and y = 1.

In the case of the `switch-case` instruction, it is required that the variable in the `switch` statement takes all possible values specified in the `case` fragments. The construction


switch(x)
  case y1: ... break;
  case y2: ... break;
  ...
  case yn: ... break;
```

can be expressed as a multiple `if-then-else` instruction:


if (x == y1) then
  ...
else if (x == y2) then
  ...
else if (x == yn) then
  ...
endif

Accepting one of the logical conditions in a `switch-case` instruction as true automatically implies that the remaining conditions are logically false.

**Decision**  – a point in a program where the control flow has two or more alternative paths; a node in the control flow graph from which two or more branches emerge.

Just like in the case of branch coverage, in the decision coverage criterion we add a formal condition of instruction coverage, so that the criterion subsumes instruction coverage for programs composed of single basic blocks, not involving any branching

Task 3

sectionThe 9.3.1,error parthypothesis 3.states Translatethat errors can occur due to a specific control flow, determined by decisions made in decision instructions. Let's consider the belowfollowing textsimple example from listing 9.2.

1 x:=0;
2 if (a>b) then
3   x:=x+1
4 endif
5 y:=100/x

Listing 9.2. A simple program

Assuming values of a and deleteb such that a > b will cause instructions 1, 2, 3, 4, 5 to be executed and will result in full instruction coverage of this fragment. However, note that if instruction 3 is not executed, the picturevariable x will retain a value of 0, and in line 5, we divide by x. Division by 0 is not allowed and performing such an operation may result in a crash or unexpected behavior of the program or operating system. By applying the instruction coverage criterion, we might not foresee testing the program in this way. However, these situations can be verified using the decision coverage criterion. It requires the existence of at least one test case in which the predicate in line 2 has a false value. This causes division by 0 in line 5 and a crash.

image.pngTest conditions in this method are basic blocks containing decisions, such as if, for, while, switch-case instructions, etc. For a given test condition, the coverage elements are all possible logical values (true and false) that the decision corresponding to that condition can take. If the program does not contain branches, the test conditions and coverage elements are instructions, just as in the instruction coverage criterion.

Table 9.6 summarizes the decision testing method.

Task 4

section 9.3.1, part 4. Translate the below text and delete the picture

image.png