|APPROACH||Coverage based - Conditions|
|TEST BASIS||Functional design|
With almost every system, there are decision points, where the system behaviour can go in different directions, depending on the outcome of such a decision point.
|Definition: A decision point is a combination of one or more conditions that define the conditions for the various possibilities in the subsequent system behaviour.|
The various conditions collectively determine the outcome of the decision point. The way in which a condition contributes to the outcome is reflected in terms such as “AND” or “OR”. There is a special kind of mathematics – Boolean algebra, or proposition logic – for the manipulation of these types of constructions. This chapter employs the theory of Boolean algebra, but the intention is not to instruct on this, and the interested reader is referred to the countless books on this subject. Below are the most important basic principles of Boolean algebra that are necessary for the techniques for covering decision points. Take, for example, the following decision point that consists of only one condition: IF (number of books > 8) THEN extra discount
Decision points that consist of such singular conditions lead to two test situations, namely the situation in which the condition is true and the situation in which the condition is false. In Boolean algebra, 0 is used to indicate that something is false; 1 is used if something is true. In our example, this refers to the following test situations:
|Number of books||> 8||≤ 8|
|Results||True (1)||False (0)|
Decision points can also consist of combinations of conditions, the so-called compound condition. Compare the following compound conditions:
IF ( Number of books > 8 OR sum ≥ €250 ) THEN extra discount
IF ( Number of books > 8 AND sum ≥ €250 ) THEN extra discount
Often an abbreviation is used by replacing the conditions by a capital letter (A, B, etc.) The two decision points mentioned above are thus abbreviated to:
A OR B and
A AND B
A compound condition is also either true or false, depending on the truth values of the individual conditions and the way in which the conditions are connected (the so-called operators): by an AND or an OR. With two conditions, the following combinations are possible:
This is called the complete decision table.
In the 0-0 situation, both statements are false. In the 0-1 situation and the 1-0 situation, only one of the two statements is true and in the 1-1 situation, both are true. The end result in each of the 4 situations depends on the operator “AND” or “OR”: with an “AND” the end result of two conditions is only true if both individual conditions are true; in all the other cases, the end result is false. With an “OR” the reverse is the case: the end result is only false if both individual conditions are false; in all the other cases the end result is true.
A common way of demonstrating the outcomes of all the situations of a complete decision table is the truth table. Below shows the truth tables for the compound conditions "A OR B" and "A AND B".
|A||B||A or B||A||B||A and B|
For a decision point that consists of, not two, but three conditions, the complete decision table is as follows:
Clearly, the number of situations increases exponentially with the number of conditions. With 6 conditions, there are already 64 situations.
Where there is a mixture of operators (AND and OR) in a compound condition, the outcome depends on which operator is executed first. To avoid confusion, it is best to indicate this by using brackets. In the absence of brackets, the rule is that the AND goes before the OR. As an example, the truth table is shown below for the compound condition "(A OR B) AND C".
|A||B||C||(A or B) and C|
Although many different Boolean operators exist, it appears that every operator can be brought back to a combination of 3 elementary operators: AND, OR and NOT. That means that if the tester knows how to deal with these 3 operators, he can tackle every decision point. (The operator "NOT" is not dealt with here; the effect of this operator is insignificant: the outcome "1" is converted to "0" and vice versa.)
The commonest coverage types in relation to decision points
The complete decision table defines all possible combinations of the individual conditions. Therefore, the testing of all these possibilities is the most thorough coverage type in respect of a decision point, and is known as "multiple condition coverage". In addition, there are various coverage types with which a subset of the complete decision table is tested. This does not refer to a random subset, but to a subset with a specific goal. Table below describes in brief the commonest coverage types and their comparative degree of thoroughness. A more thorough coverage type 'implies' a less thorough coverage type, i.e.: one that covers minimally all the test situations of the elementary coverage type.
The possible outcomes of ("true" or "false") for each condition are tested at least once.
The possible outcomes of the decision are tested at least once.
The possible outcomes of each condition and of the decision are tested at least once.
Every possible outcome of a condition determines at least once the outcome of the decision.
All the possible combinations of outcomes of conditions in a decision (therefore the complete decision table) are tested at least once.
The example below illustrates the differences between the coverage types mentioned.
In more detail:
Take the following decision point as an example:
Multiple Condition coverage
For the most elementary coverage type, the best choice is "condition/decision coverage", which fulfils both "condition coverage" and "decision coverage", and requires the same number of test situations.
The coverage type "modified condition/decision coverage" is a very powerful means of obtaining thorough coverage with a small number of test situations. This coverage type is not readily mastered by everyone. For that reason, it is explained in depth in the following section.
Read more in the Modified Condition/Decision coverage wiki.