ISTQB Certified Tester Foundation Level
Static testing vs dynamic testing for ISTQB CTFL
Static testing examines a work product without executing it, by review or static analysis, and finds defects directly. Dynamic testing executes the software and causes failures, and the defects behind them are found by later analysis. ISTQB's CTFL v4.0 syllabus says the two complement each other, and some defect types can be found by only one of them.
What can static testing examine?
Nearly every kind of work product. Examples are requirement specifications, product backlog items, source code, models, contracts, project documentation, and testware such as test plans, test cases and test charters.
The two forms have different conditions. A review needs only a work product that people can read and understand. Static analysis needs a structure to check the work product against, such as code, a model, or text with a formal syntax. Spelling checkers and readability tools count as static analysis tools.
Work products that are hard for people to interpret and that should not be analysed by tools are not suitable. The syllabus gives third-party executable code, which may be off limits for legal reasons, as the example.
How do static and dynamic testing differ?
Static testing finds defects directly. Dynamic testing causes failures, and the defects are determined afterwards by analysing them.
Static testing can more easily find defects on code paths that seldom run or that dynamic tests struggle to reach. It also finds defects that dynamic testing cannot detect at all, such as code that can never be reached, a design pattern implemented differently from what was intended, and defects in work products that cannot be executed.
Static testing applies to non-executable work products. Dynamic testing applies only to executable ones. Static testing can measure quality characteristics that do not depend on running code, such as maintainability. Dynamic testing measures those that do, such as performance efficiency.
Which defects is static testing better at finding?
The syllabus lists defects that are easier or cheaper to find statically. In requirements: ambiguities, omissions, contradictions, inconsistencies, inaccuracies and duplications. In design: poor modularization or an inefficient database structure. In code: undeclared variables, variables whose value is undefined, duplicated or unreachable code, and code that is too complex. The list also has deviations from standards such as naming conventions, interface specifications whose parameters differ in number, type or order, some security vulnerabilities such as buffer overflows, and gaps in test basis coverage such as an acceptance criterion with no test.
On cost: reviews can be expensive to carry out, but a project that uses them usually costs far less in total than one that does not, because less time and effort goes into fixing defects later. Static analysis finds certain code defects more efficiently than dynamic testing does, which usually means fewer code defects and lower overall development effort.
Where the exam catches people
- Believing static testing applies only to code: nearly any work product qualifies, including requirements, test plans, contracts and models.
- Believing static analysis can be run on any document: it needs a structure to check against, such as code, a model or a formal syntax. A review needs only that the work product can be read and understood.
- Believing dynamic testing can find unreachable code: code that never executes cannot cause a failure, so only static testing finds it.
- Assigning maintainability to dynamic testing and performance efficiency to static testing: it is the other way round.
- Believing reviews raise total project cost: they usually lower it, because defects are removed before they need expensive fixes.
Written from these sources
- ISTQB CTFL Syllabus v4.0.1, section 3.1 Static Testing Basics (page 33)
- ISTQB CTFL Syllabus v4.0.1, section 3.1.1 Work Products Examinable by Static Testing (page 33)
- ISTQB CTFL Syllabus v4.0.1, section 3.1.2 Value of Static Testing (page 33)
- ISTQB CTFL Syllabus v4.0.1, section 3.1.3 Differences between Static Testing and Dynamic Testing (page 34)