Condition testing techniques
An overview of condition testing techniques.
The purpose of this set of testing methods is to build test cases for testing the logical conditions of the program. In this case, coverage of operators from all branches of the program will be a plus.
Let’s study the terminology used here.
A simple condition is a Boolean variable or a relational expression.
The relational expression has the form
E1 <relational operator> E2,
where E1, E2 are arithmetic expressions, and as the relational operator one of the following operators is used: <, >, =, ≤, ≥.
A compound condition consists of several simple conditions, Boolean operators and parentheses. We will use the Boolean operators OR, AND (&), NOT. Conditions that do not contain relational expressions are called Boolean expressions.
Thus, the condition elements are: a Boolean operator, a Boolean variable, a pair of parentheses (enclosing a simple or compound condition), a relational operator, an arithmetic expression. These elements determine the types of errors in the conditions.
If the condition is incorrect, at least one of the condition elements is incorrect. Consequently, the following types of errors are possible in the condition:
– Boolean operator error (presence of incorrect / missing / redundant Boolean operators);
– Boolean variable problem;
– Boolean parenthesization problem;
– relational operator error;
– Arithmetic expression error.
The condition testing technique is focused on testing each condition in the program. Testing conditions methods have two advantages. Firstly, it is quite easy to measure the condition coverage testing. Secondly, the condition coverage testing in the program is the basis for generating additional tests of the program.
The purpose of conditional testing is to determine not only the errors in the conditions, but also other errors in the programs. If the set of tests for A program is effective for detecting errors in conditions contained in A, then it is possible that this set is also effective for detecting other errors in A. Besides, if the testing technique is effective for detecting errors in a condition, then it is possible that this technique will be effective for detecting errors in the program.
Methods for Condition Testing
There are several methods for condition testing.
The simplest technique is branch testing. Here, for compound condition C, we check:
– every simple condition (included in it);
– True-branch;
– False-branch.
Another technique is domain testing. It requires the generation of 3-4 tests to express the relation. An expression of the form
E1 <relational operator> E2
is checked by three tests that form the value of E1 greater than E2 equal to E2 and less than E2.
If the relational operator is incorrect, and E1 and E2 are correct, then these three tests guarantee the detection of the error of the relational operator.
To determine the errors in E1 and E2, the test should generate a value of E1 greater or less than E2, and to ensure the smallest difference between these values.
For Boolean expressions with n variables, a set of 2n tests is required. This set allows to detect errors of Boolean operators, variables and parentheses, but it is practical only for small n. However, if each Boolean variable enters the Boolean expression only once, then the number of tests is easily reduced.
In the next article we will discuss the method of conditional testing based on the techniques above.