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
Exercise
For each defect below, say whether static testing (review/static analysis) or dynamic testing (execution) is the efficient way to catch it, and why.
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?