ISTQB Foundation/Ch.3 · Static Testing (7%) · Topic 1

Static vs Dynamic Testing

Explain what static testing can catch that dynamic testing structurally cannot, and vice versa.

Static testing evaluates a work product without executing it — reviews (manual) and static analysis (tool-driven). Because it doesn't require running code, it applies to almost any artifact: requirements, user stories, designs, test cases, and code itself, long before there's anything a dynamic test could even execute against. Dynamic testing, by contrast, requires executing the component or system and observing actual behavior against expected.

Static testing catches classes of problem dynamic testing structurally can't reach cheaply: an ambiguous or missing requirement (there is no code yet to run a test against), unreachable code, an unused variable, or a coding-standard violation a compiler won't flag. Dynamic testing catches what only shows up when the system actually runs: a race condition under real concurrency, an incorrect calculation with real data, actual performance under real load.

Both are needed, and static testing is disproportionately cheap for what it prevents: fixing an ambiguous requirement during review costs a sentence; the same ambiguity, coded and shipped, costs the full round trip of investigation, hotfix, redeploy and support.

Real-world use case

A requirement says "passwords must be strong." No dynamic test can be written against that sentence — there's no defined pass/fail. A static review that turns it into "minimum 12 characters, at least one number and one symbol" is what makes the feature testable at all, and it happens before a single line of implementation exists.

Example code

Best caught by static testing vs dynamic testing
STATIC TESTING catches well             DYNAMIC TESTING catches well
- Ambiguous/missing requirement          - Wrong output for a real calculation
- Unreachable code, dead branches        - Memory leak under sustained load
- Coding standard violations             - Race condition under real concurrency
- A typo in a user story's condition     - Actual response time under load

Exercise

Sort the defect: static or dynamic testing catches it best?

For each defect below, say whether static testing (review/static analysis) or dynamic testing (execution) is the efficient way to catch it, and why.

// 1. A function has a branch that can never be reached given the calling code.

// 2. The checkout total is off by $0.01 on orders with three specific coupon
//    codes stacked together.

// 3. A user story says "the report should load quickly" with no defined
//    threshold.

Read-only here — open the English track at /learn to write and edit this exercise.

Quiz (3)

1. Which of these is a defect static testing is well suited to catch, before any code runs?

2. Static analysis tools typically detect which of the following without executing the program?

3. Why is fixing an ambiguous requirement during review cheaper than fixing the same ambiguity after release?