Whitebox Testing

1 / 20
About This Presentation
Title:

Whitebox Testing

Description:

Assumes errors at unit level are in the control structure or data path. Generates test cases to test ... AT&T 4ESS switch meltdown. Unit Module Specification ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 21
Provided by: Robert9

less

Transcript and Presenter's Notes

Title: Whitebox Testing


1
Whitebox Testing
  • CS2335
  • Fall 2001

2
Whitebox Testing
  • AKA Structural, Basis Path Test
  • Normally used at unit level
  • Assumes errors at unit level are in the control
    structure or data path
  • Generates test cases to test control paths
    through the code
  • Criteria includes Control-Flow and Data-Flow
    based coverage

3
Coverage Criteria
  • Control Flow based
  • Statement Coverage (All nodes)
  • Branch (or Decision) Coverage (All edges)
  • All Paths
  • Data Flow based
  • All DU paths
  • All C uses
  • All Defs
  • Etc

4
Motivation
What happens when good software goes bad? ATT
4ESS switch meltdown
5
Unit Module Specification
Invoices are calculated using the following
algorithm Item X sells for 5 and Item Y sells
for 10 Invoice Total gt200 get 5 discount
Invoice Total gt1000 get 10 discount
Invoices that order more than 30 X items
get a 5 discount
6
Example Program
int invoice (int x, int y) int d1, d2, s
if (xlt30) d2100 else d290 s5x 10
y if (slt200) d1100 else if (slt1000) d1
95 else d1 80 return
(sd1d2/10000)
7
Statement Coverage
8
Branch Coverage
9
Path Coverage
With loops impossible
6 Test Cases
10
Data Flow Testing
  • All du paths
  • All u
  • All c / some p
  • All p / some c
  • All d
  • All p

11
Some Definitions
  • Definition-Use (sub)path wrt variable v such
    that DEF(v,m) and USE(v,n) and m, n are the
    initial and final nodes of the (sub)path.
  • Definition-Clear (sub)path wrt variable v such
    that DEF(v,m) and USE(v,n) and not other node in
    the subpath is a DEF node for v

12
Data FlowTesting
x, y, d1, d2, s
if
p
d d d d
1
sgt1000
xgt30
if
p
d
6
d
2
3
d
d
7
4
c c
d
sgt200
if
p
8
c c c
d
5
13
Exercise 1
void handleCommandModeKeypress(char c) if
(c) startMulticharCommand( c ) else if
(cgt0 c lt9) doRepeatedCommand( c )
else switch(c) case x
doSingleCharDelete( ) break case
d doLineDelete( ) break
Generate Test Cases for Statement Branch
Paths
14
Solution
C
Cgt0
Clt9
Cd
Cx
15
Dataflow Solution
d
No new test paths??
p
p
p
c
p
c
16
Dataflow Anomolies
  • dd harmless, but suspicious
  • kk possible bug
  • kd normal
  • ku bug
  • -k possible bug
  • -u bug

17
Strength of Coverage
All Paths
All du Paths
All u
All c some p
All p some c
All d
All p
Branch
Statement
18
How effective?
Strategy Mean Cases Bugs Found Random Testing
100
79.5 Branch Testing 34
85.5 All Uses
84
90.0
19
Exercise 2
void doRepeatedCommand(char c) char
buffer256 int index0 int value 0
while (cgt0 clt9) bufferindexc
cgetch() bufferindex\0
valueatoi(buffer) for (index0indexltvaluein
dex) handleSingleCommand( c )
20
Next Time
Specification-Based / Blackbox Testing
DEFECTUS ELIMINATO
Write a Comment
User Comments (0)