Foundation Level study guide

Control Flow Graph (CFG)

A Control Flow Graph (CFG) is a visual representation of all paths that might be traversed through a program during its execution. It is the foundational tool QA engineers use to calculate white-box coverage metrics.

Practical example

A CFG consists of Nodes (representing blocks of executable statements) and Edges (the directional arrows representing the flow of control, such as True/False decisions). To calculate Branch Coverage, the tester simply counts the total number of Edges exercised by their test cases and divides it by the total number of Edges in the entire graph.

Exam scenario and common trap

Scenario: A tester counts the number of physical lines of code in a Java method to determine how many test cases are needed for 100% Branch Coverage. The Trap: "More lines of code equals more test cases." The Correct Answer: Code length is irrelevant. The number of tests depends on the graph and feasible paths; code length or the number of IF statements alone is insufficient to calculate it. You must look at the decision nodes, not the line count.

Related syllabus material covers the broader concept; this page includes additional context. Reference sections: 4.3.2. See the official ISTQB syllabus for exam scope. Examples are independent; QA-ace is not affiliated with ISTQB.