Software Testing

Control Flow

Construct control flow graphs from program source and analyze coverage criteria — node, edge, condition, and path coverage.

Source (JavaScript / Java)

Each function becomes its own graph (one component). A call to a function defined here is a local call — click it to jump to its graph; anything else is an external call.

Cyclomatic complexity (module)
4M = E − N + 2P = 13 − 13 + 2·2
P = 2 components (one per function). Module M equals the sum of the per-function values: Σ Mᵢ = 4.

Per-function complexity

Nodes (N)
13
Edges (E)
13
Components (P)
2
Functions
2
Decisions
2
Calls
3

Node types

Start / End
Statement block
Decision (predicate)
External call
Local call (click to follow)
Decision edges are labelled T (true) / F (false). Drag nodes to rearrange; scroll to zoom.
TFTFisValidisValidEndEnduser == nulluser == nullreturn falsereturn falsereturn user.age >= 18return user.age >= 18registerregisterEndEndlet ok = isValid(user)let ok = isValid(user)okoksaveToDb(user)saveToDb(user)sendEmail(user)sendEmail(user)return "ok"return "ok"return "rejected"return "rejected"