0
597views
Control Structure Testing
1 Answer
0
5views

Control structure testing is a group of white-box testing methods.

Branch Testing

Condition Testing

Data Flow Testing

Loop Testing

1) Branch Testing:- For every decision, each branch needs to be executed at least once also called decision testing.

shortcoming - ignores implicit paths that result from compound conditionals.

Treats a compound conditional as a single statement. (We count each branch taken out of the decision, regardless which condition lead to the branch.)

This example has two branches to be executed:

IF ( a equals b) THEN statement 1

ELSE statement 2

END IF

This examples also has just two branches to be executed, despite the compound conditional:

IF ( a equals b AND c less than d ) THEN statement 1

ELSE statement 2

END IF

This example has four branches to be executed:

IF ( a equals b) THEN statement 1

ELSE

IF ( c equals d) THEN statement 2

ELSE statement 3

END IF

END IF

Obvious decision statements are if, for, while, switch.

Subtle decisions are return boolean expression, ternary expressions, try-catch.

For this course you don't need to write test cases for IO Exception and Out Of Memory exception.

2) Condition Testing:-

Condition testing is a test construction method that focuses on exercising the logical conditions in a program module.

Errors in conditions can be due to:

Boolean operator error

Boolean variable error

Boolean parenthesis error

Relational operator error

Arithmetic expression error

definition: "For a compound condition C, the true and false branches of C and every simple condition in C need to be executed at least once."

Multiple-condition testing requires that all true-false combinations of simple conditions be exercised at least once.

Therefore, all statements, branches, and conditions are necessarily covered.

3) Data Flow Testing:-

Selects test paths according to the location of definitions and use of variables. This is a somewhat sophisticated technique and is not practical for extensive use. Its use should be targeted to modules with nested if and loop statements.

4) Loop Testing:-

Loops are fundamental to many algorithms and need thorough testing.

There are four different classes of loops: simple, concatenated, nested, and unstructured.

enter image description here

Examples:

Create a set of tests that force the following situations:

  • Simple Loops, where n is the maximum number of allowable passes through the loop.

  • Skip loop entirely

  • Only one pass through loop o Two passes through loop

  • m passes through loop where m<n.< p="">

  • (n-1), n, and (n+1) passes through the loop.

Nested Loops:-

  • 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.

Concatenated Loops:-

  • If independent loops, use simple loop testing.

  • If dependent, treat as nested loops.

Unstructured loops

  • Don't test - redesign.
Please log in to add an answer.