Explain control structure testing.

Subject: Software Engineering

Topic: Software Testing

Difficulty: Medium

software engineering • 12k  views

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


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


This example has four branches to be executed:

IF ( a equals b) THEN statement 1


IF ( c equals d) THEN statement 2

ELSE statement 3



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


Create a set of tests that force the following situations:

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

o Skip loop entirely

o Only one pass through loop o Two passes through loop

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

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

Nested Loops:-

o Start with inner loop. Set all other loops to minimum values.

o Conduct simple loop testing on inner loop.

o Work outwards

o Continue until all loops tested.

Concatenated Loops:-

o If independent loops, use simple loop testing.

o If dependent, treat as nested loops.

Unstructured loops

o Don't test - redesign.

Please log in to add an answer.

Continue reading

Find answer to specific questions by searching them here. It's the best way to discover useful content.

Find more