Ch 11. Control Flow, Data Dependency, and Interaction Testing

25
Dependency, and Interaction Testing General Types of Interaction in Execution. Control Flow Testing (CFT) Data Dependency Analysis Data Flow Testing (DFT)

description

Ch 11. Control Flow, Data Dependency, and Interaction Testing. General Types of Interaction in Execution. Control Flow Testing (CFT) Data Dependency Analysis Data Flow Testing (DFT). Finite State Machines (Ch10). Good for testing interconnected system functions and related usage - PowerPoint PPT Presentation

Transcript of Ch 11. Control Flow, Data Dependency, and Interaction Testing

Page 1: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Ch 11. Control Flow, DataDependency, and Interaction Testing

General Types of Interaction in Execution.

Control Flow Testing (CFT)

Data Dependency Analysis

Data Flow Testing (DFT)

Page 2: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Finite State Machines (Ch10) Good for testing interconnected system

functions and related usage UBST with Markov-Ops

Difficulties with FSMs state explosions only do one-step links complex interactions

Page 3: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Interactions in program execution: Interaction along the execution paths:

later execution affected by earlier stages focus in on execution paths rather than state or link

coverage tested via control flow testing (CFT) analysis: control flow graph (CFG) – special type of FSM

Computational results affected too: specific interactions among data items in execution

data dependency through execution tested via data flow testing (DFT) analysis: data dependency graph (DDG)

Page 4: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFGs Basis for control flow testing (CFT).

CFGs elements: processing & I/O in nodes

links: “is-followed-by" relation, some annotated with conditions.

no work associated with links; no duplicate links as in FSMs link types: unconditional and conditional, latter marked by

branching conditions.

Page 5: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFG: Nodes and Links Inlink and outlink defined w.r.t a node. Nodes:

Entry (source/initial) nodes. Exit (sink/final) nodes. Processing nodes (P). Branching & junction nodes & links (C):

Branching/decision/condition nodes: multiple outlinks, marked by a specific condition

Junction nodes (J): opposite to branching nodes, no need to mark

2-way and N-way branching/junction.

Conventions: single-entry/single-exit and no GOTOs.

Page 6: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT Technique Test preparation:

Build and verify the model (CFG) Test cases:

CFG => Select path to follow Sensitize paths or test cases by deciding input values

Plan for result checking

Other steps: Standard (Ch.7) Test planning & procedure preparation. Execution: normal/failure case handling. Analysis and Follow-up

Page 7: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT: Constructing CFG

Sources for CFG: White box: design (flowchar) or code Black box: structure and relations in specifications

Page 8: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Program-derived (white-box) CFGs Processing: assignment and calls Branch statements:

binary: if-then-else, if-then multi-way: switch-case, cascading if's.

Loop statements (later) explicit/implicit entry/exit super-nodes – don’t affect execution paths Composition: concatenating (Fig 11.1) and

nesting (Fig 11.2). Structured programming: no GOTOs

hierarchical decomposition always possible.

Page 9: Ch 11. Control Flow, Data Dependency, and Interaction Testing
Page 10: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Specification-derived Control Flow Graphs From external specifications (bottom pg. 179)

Node: “do" (enter, calculate, etc.) Branch: “goto/if/when/while/..." Loop: “repeat" (for all, until, etc.) Entry: usually implicit Exit: explicit and implicit External reference as process unit General sequence: “do"...(then)...”do".

Other info sources: user-related items usage-scenarios/traces/user-manuals, high-level requirements and market analyses.

Page 11: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT: Path related concepts/definitions

Path: entry to exit via n intermediate links and nodes.

Path segment or sub-path: proper subset of a path.

Loop: path or sub-path with 1+ nodes visited 1+ times.

Testing based on sub-path combinations.

Loop testing: specialized techniques.

Page 12: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT: Path Selection Path selection (Divide & Conquer)

“Divide": hierarchical decomposition for structured programs.

“Conquer": Bottom-up path definition one segment at a time via basic cases for nesting and sequential concatenation.

Page 13: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT: Path Selection Graph G made up of G1 and G2 subgraphs, with

M and N branches, respectively Subgraph: 1 entry + 1 exit. Key decisions at entry points.

Path segment composition: Sequential concatenation: G = G1 ° G2

M X N combined paths.

Nesting: G = G1 (G2) M + N - 1 combined paths.

Page 14: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Example based on Fig 11.1 (p.177) Example subgraphs

G = G1 ° G2 (-, G3) where (-,G3) indicates G3 nested in G2 in the False branch

Example subpaths Sequential concatenation: G = G1 ° G2

M X N combined paths (M=2 and N=2, so 4 paths).1. P1, C1, P2, J1, C2, P4, J3, P7

2. …

Nesting: G2 (-, G3) M + N - 1 combined paths (M=2 and N= 2, so 3 paths).

1. C2, C3, P5, J2, J3, P7

2. …

Page 15: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT: Sensitization Path sensitization/realization

Logic: constant predicates. eg. TT-, TFT, … Algebraic: variable predicates. eg. (x >0), (y <100), (z=10) use 1, 1024, 10 Use simple, obvious test cases and rely on good application knowledge Obtain input values (test point)

Trouble sensitize => check others first. Unachievable/infeasible path?

if (y < 0) x = y –1;

else x = y+1;

if (x > 0) … then-then infeasible Model/specification bugs? data dependency issues – use DFT.

Page 16: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT: Other Steps Execution and follow-up:

Path/statement-oriented execution debugger and other tools helpful

Follow-up: coverage and analysis Outcome prediction and confirmation:

Test oracle or outcome prediction: Path confirmation/verification. Guard against coincidental correctness.

read x;y = x + 2; vs. y = x * 2;write y;

Can’t distinguish if input is 2 Implies one point per path is insufficient

Automation: dynamic execution path and related tracing.

Page 17: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Loops: What and Why Loop: What is it?

Repetitive or iterative process. Graph: a path with one or more nodes visited

more than once. Recursion.

Why is it important? Intrinsic complexity:

coverage: how much? effectiveness concerns (complete coverage

impractical) Practical evidence: loop defects

Page 18: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Loop Specification Definite vs. indefinite.

Individual loops: Loop control: node, predicate, and control

variable. Loop entry/exit. Processing and looping: pre-test, post-test,

mixed-test. Example: Fig 11.3 (p.183)

commonly used “while" and “for" loops.

Page 19: Ch 11. Control Flow, Data Dependency, and Interaction Testing
Page 20: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Loop Testing Path coverage:

All: infeasible for nested loops:

Works for i iterations => i+1 iterations most likely fine too. Important: how to select?

heuristics and concrete measures boundary related problems more likely

Hierarchical modeling/testing: Test loop in isolation first. Collapse loop as a single node in higher level models.

1

11

0

N

N MM

i

i

N

Page 21: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Critical Values for Loop Testing General boundary problems:

Under/over defined problems and closure problems. Similar to boundary testing (Ch.9).

Lower bound problems: Initialization problem. Loop execution problem of empty, single item cases. Other boundary problems.

Lower bound test values: Bypass, once, twice. Min, min + 1, min - 1.

Page 22: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Critical Values for Loop Testing Upper bound problems:

Primarily ±1 problem Capacity problem Other boundary problems

Upper bound test values: Max, max + 1, max - 1; Practicality: avoid max combinations; Testability: adjustable max. Related: capacity/stress testing

Page 23: Ch 11. Control Flow, Data Dependency, and Interaction Testing

Critical Values for Loop Testing Other critical values:

Typical number (usage-based testing); Implicit looping assumptions in hierarchical models

Generic test cases: Lower bound: always exists => related critical values. Upper bound: not always exists

if so => related critical values, if not => related capacity testing.

Other critical values.

Page 24: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT Usage As white box testing (more often):

Small programs during unit testing. Large program – use coarse-grain system level model.

As black box testing (less often): Model built on specification

higher level constraints as specs.

Overall coverage of functionality. Can be used for UBST.

Application environment: Control flow errors (& decision errors). In combination with other techniques.

Page 25: Ch 11. Control Flow, Data Dependency, and Interaction Testing

CFT: Other Issues Limit control flow complexity

Proper granularity Hierarchical modeling ideas:

external units/internal blocks Combination with other strategies:

CFT for frequently-used/critical parts Language/programming methodology Complexity measurement as guidelines

Need automated support: Models from specifications/programs Sensitization support -- debugging Path verification -- tracing