N is a Control Structure That Continues to Be Performed While a Test Condition is True
Control Structure Testing
Control structure testing is used to increase the coverage area by testing various control structures present in the program. The different types of testing performed under control structure testing are as follows-
1. Condition Testing 2. Data Flow Testing 3. Loop Testing
1. Condition Testing : Condition testing is a test cased design method, which ensures that the logical condition and decision statements are free from errors. The errors present in logical conditions can be incorrect boolean operators, missing parenthesis in a booleans expression, error in relational operators, arithmetic expressions, and so on. The common types of logical conditions that are tested using condition testing are-
- A relation expression, like E1 op E2 where 'E1' and 'E2' are arithmetic expressions and 'OP' is an operator.
- A simple condition like any relational expression preceded by a NOT (~) operator. For example, (~E1) where 'E1' is an arithmetic expression and 'a' denotes NOT operator.
- A compound condition consists of two or more simple conditions, Boolean operator, and parenthesis. For example, (E1 & E2)|(E2 & E3) where E1, E2, E3 denote arithmetic expression and '&' and '|' denote AND or OR operators.
- A Boolean expression consists of operands and a Boolean operator like 'AND', OR, NOT. For example, 'A|B' is a Boolean expression where 'A' and 'B' denote operands and | denotes OR operator.
2. Data Flow Testing : The data flow test method chooses the test path of a program based on the locations of the definitions and uses all the variables in the program. The data flow test approach is depicted as follows suppose each statement in a program is assigned a unique statement number and that theme function cannot modify its parameters or global variables. For example, with S as its statement number.
DEF (S) = {X | Statement S has a definition of X} USE (S) = {X | Statement S has a use of X}
If statement S is an if loop statement, them its DEF set is empty and its USE set depends on the state of statement S. The definition of the variable X at statement S is called the line of statement S' if the statement is any way from S to statement S' then there is no other definition of X. A definition use (DU) chain of variable X has the form [X, S, S'], where S and S' denote statement numbers, X is in DEF(S) and USE(S'), and the definition of X in statement S is line at statement S'. A simple data flow test approach requires that each DU chain be covered at least once. This approach is known as the DU test approach. The DU testing does not ensure coverage of all branches of a program. However, a branch is not guaranteed to be covered by DU testing only in rare cases such as then in which the other construct does not have any certainty of any variable in its later part and the other part is not present. Data flow testing strategies are appropriate for choosing test paths of a program containing nested if and loop statements. 3. Loop Testing : Loop testing is actually a white box testing technique. It specifically focuses on the validity of loop construction. Following are the types of loops.
- Simple Loop – The following set of test can be applied to simple loops, where the maximum allowable number through the loop is n.
- Skip the entire loop.
- Traverse the loop only once.
- Traverse the loop two times.
- Make p passes through the loop where p<n.
- Traverse the loop n-1, n, n+1 times.
- Concatenated Loops – If loops are not dependent on each other, contact loops can be tested using the approach used in simple loops. if the loops are interdependent, the steps are followed in nested loops.
- Nested Loops – Loops within loops are called as nested loops. when testing nested loops, the number of tested increases as level nesting increases. The following steps for testing nested loops are as follows-
- Start with inner loop. set all other loops to minimum values.
- Conduct simple loop testing on inner loop.
- Work outwards.
- Continue until all loops tested.
- Unstructured loops – This type of loops should be redesigned, whenever possible, to reflect the use of unstructured the structured programming constructs.
white-haneyyouresser1937.blogspot.com
Source: https://www.geeksforgeeks.org/control-structure-testing/