White-Box Test Techniques

.
Software Testing / Chapter 04 01 / 06

White-Box
Test Techniques.

Statement testing · Branch testing
Based on an analysis of the test object's internal structure.
◉ ISTQB FOUNDATION · SECTION 4.3
The focus · two code-related techniques 02 / 06
Because of their popularity and simplicity

The entire software implementation is taken into account.

There are more rigorous white-box test techniques used in safety-critical, mission-critical, or high-integrity environments. There are also techniques used in higher test levels, such as API testing. These are not discussed in this syllabus.

Technique 01
S

Statement Testing.

Coverage items are executable statements. The aim is to exercise statements in the code until an acceptable level of coverage is achieved.

Technique 02
B

Branch Testing.

Coverage items are branches. The aim is to exercise branches (transfers of control) in the code until an acceptable level of coverage is achieved.

4.3.1 · Statement Testing 03 / 06
Exercising executable statements

Each statement with a defect will be executed.

When 100% statement coverage is achieved, all executable statements in the code have been exercised at least once. This may cause a failure demonstrating the presence of the defect.

However, exercising a statement will not detect defects in all cases. It may not detect data-dependent defects, and it does not ensure that all decision logic has been tested.

Covers all executable statements100%
May miss data-dependent defectsGAP
May not exercise all branchesGAP
Formula
Exercised/ TOTAL
4.3.2 · Branch Testing 04 / 06
Transfers of control

Conditional and unconditional branches.

A branch is a transfer of control between two nodes in the control flow graph. Conditional branches typically correspond to a true or false outcome from an "if...then" decision, a switch/case outcome, or a decision to exit or continue in a loop.

Exercising a branch will not detect defects in all cases — for example, defects requiring the execution of a specific path in code.

if...then decisionsCONDITIONAL
switch/case outcomesCONDITIONAL
Loop continue/exitCONDITIONAL
Straight-line codeUNCONDITIONAL
Branch coverage subsumes statement coverage. 100% branch coverage also achieves 100% statement coverage — but not vice versa.
4.3.3 · The Value of White-box Testing 05 / 06
Fundamental Strength

Entire
implementation
accounted for.

Facilitates defect detection even when the software specification is vague, outdated, or incomplete. The code itself is the source of truth.

&
Corresponding Weakness

Defects
of omission.

If the software does not implement one or more requirements, white-box testing may not detect the resulting missing functionality.

Performing only black-box testing does not provide a measure of actual code coverage. White-box coverage measures provide an objective measurement of coverage.
Conclusion · structure-based techniques 06 / 06
Objective measurement of coverage

Necessary information to increase confidence.

— TECHNIQUE / 01
Statement
— TECHNIQUE / 02
Branch
— APPLICATION
Static & Dynamic
White-box techniques can also be used in static testing — well suited to reviewing code not yet ready for execution, pseudocode, and other high-level logic which can be modeled with a control flow graph.
.