Skip to main content

Description of the method

Task 1

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.

Task 2

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

image.png

Task 3

The error hypothesis states that errors can occur due to a specific control flow, determined by decisions made in decision instructions. Let's consider the following simple 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 b 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 variable 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.

Test 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