Control Flow Graph
- A Control Flow Graph (CFG) models all executions of a method by describing control structures.
- Nodes: Statements or sequences of statements (basic blocks).
- Basic Block: A sequence of statements such that if the first statement is executed, all statements will be (no branches).
- Edges: Transfer of control from one statement to the next.
- CFGs are often annotated with extra information to model data:
- Branch predicates.
- Defs and/or uses.
Graph Coverage Criteria: Applied to test code
Structural Graph Coverage Criteria
CFG: If statement
CFG: If statement with return
CFG: Switch case
CFG: While Loop
CFG: For Loop