A set of inputs and expected outputs.

Components include…

  1. Boilerplate / metadata
  2. Pre-conditions
  3. Inputs
  4. Expected outputs
  5. Observed outputs
  6. Pass/fail
    1. This may not always be obvious such as in the case where we are testing Performance.
    2. Flaky tests turn a pass fail into a confidence value / probability

Creating Test Cases

The key question for creating tests for a path are:

  • How do we make the path execute and how do we generate input data that satisfies all conditions on the path Key Items:
  • Input vector
    • A collection of all data entities read by the routine whose values must be fixed prior to entering the routine
    • Members include:
      • Input arguments to the routine
      • Global variables and constants
      • Files
      • Network connections
      • Timers
  • Predicate
    • A logical function evaluated at a decision point
    • These are basically the expressions in if, while loops etc
  • Path predicate
    • This is the set of predicates associated with a path
  • Predicate interpretation
    • A path predicate may contain local variables
    • Local variables play no role in selecting inputs that force a path to execute
    • Local variables are eliminated with Symbolic Execution
  • Path predicate expression
    • This is an interpreted path predicate
    • This has
      • No local variables
      • A set of constraints in terms of the input vector, and maybe constraints
      • By solving the constraints, inputs that force each path can be generated
      • If a path predicate expression has no solution, the path is infeasible
  • Create test input from path predicate expression

Path Predicate Example

Now we solve for a and b.

A program unit may contain a large number of paths. Selecting paths becomes a tradeoff.