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

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** (*Polish: decyzja*) – 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

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

image.png

Task 4

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

image.png