Def: judging test suite thoroughness based on the structure of the program itself

  • Also known as white-box testing
  • Distinguish from functional testing (black-box testing)
    • structural testing is still testing product functionality against its specification
    • only the measure of thoroughness has changed

Why need structural testing:

  • Executing all control flow elements does not guarantee finding all faults
  • Increase confidence in thoroughness of testing

Practical use:

  • Firstly create functional test suite
  • Then measure structural coverage to identify see what is missing

Statement testing & Branch testing

Statement testing:

  • Adequacy criterion: each statement must be executed at least once
  • Rationale: a fault in a statement can only be revealed by executing the faulty statement

Branch testing:

  • Adequacy criterion: each branch (edge in the CFG) must be executed at least once

Comparison:

Traversing all edges of a graph causes all nodes to be visited, so we have:

  • Test suites that satisfy the branch adequacy criterion for a program P also satisfy the statement adequacy criterion for the same program
  • A statement-adequate (or node-adequate) test suite may not be branch-adequate (edge-adequate)