Certopolis

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

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. Before release, a team must assess two quality characteristics of a new payment module: how easily it can be changed, and how fast it handles 500 concurrent requests. Which of the following is the BEST approach, according to the syllabus? Select ONE option.

    Right. In the game that’s Renown for your Static Testing building.

    Not that one: D is right. In the game your Static Testing building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    How fast the module handles 500 concurrent requests is performance efficiency, which only shows when the code runs, so dynamic testing measures it.

    Written from istqb.org/wp-content/uploads/2024/11/ISTQB_CTFL_Syllabus_v4.0.1.pdf

  2. A static analysis tool reports excessive complexity in a pricing module. The same week, a performance test shows a search screen answering in 6 seconds instead of the required 2. Which of the following statements about these two findings is CORRECT? Select ONE option.

    Right. In the game that’s Renown for your Static Testing building.

    Not that one: C is right. In the game your Static Testing building would lose a little Renown, and this question would come back later.

  3. Which of the following defects can static testing find that dynamic testing CANNOT detect at all? Select ONE option.

    Right. In the game that’s Renown for your Static Testing building.

    Not that one: C is right. In the game your Static Testing building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The wrong result for a rare input is the tempting runner-up: static testing may spot it more easily, but a dynamic test that happens to use that input will still expose it.

    Written from istqb.org/wp-content/uploads/2024/11/ISTQB_CTFL_Syllabus_v4.0.1.pdf

Ask for something