C 5: C - B T D: Oftware Esting
C 5: C - B T D: Oftware Esting
CHAPTER 5:
CRITERIA-BASED TEST
DESIGN
DESIGN
Criteria give us ABSTRACTION
test requirements LEVEL
software IMPLEMENTATION
artifact ABSTRACTION input
LEVEL values
2. Graphs
if (x > y)
z = x - y;
4. Syntactic Structures
else
(grammars) z = 2 * x;
7
1. Graph Coverage – Structural
2 6
1 5 7
Node
Edge (Statement)
3 Path(Branch)
Cover
Cover every node
Cover everyedge
every path
• 12567
• 12567
• 12567
4 • 1343567
This graph may represent • 1343567
• 1257
• statements & branches • 1357
• 13567
• methods & calls
• 1357
• components & signals
• 1343567
• states and transitions
• 134357 …
8
1. Graph Coverage – Data Flow
def = {m}
def = {a , m}
use = {y}
2 6
def = {x, y} use = {x} use = {a} use = {m}
1 5 use = {a} 7
use = {x} def = {a}
Defs
All & Uses Pairs
Defs
3 All Uses
• (x, 1, (1,2)), (x, 1, (1,3))
Every
Everydefdefused once
“reaches”
• (y, 1, 4), (y, 1, 6)
• every
1, 2, 5,use
6, 7
4 • (a, 2, (5,6)), (a, 2, (5,7)),
• •1,
(a, 3,1,
2,2,5,5,76,
(5,6)), (a,73, (5,7)),
This graph contains:
def = {m}
• defs: nodes & edges • •1,1,2,
• (m, 3,2,4,5,3,
7), 75,4,7 7), (m, 6,
(m,
use = {y}
where variables get values 7)
• 1, 3, 5, 6, 7
• uses: nodes & edges • 1, 3, 5, 7
where values are accessed
• 1, 3, 4, 3, 5,7 9
1. Graph - FSM Example
Memory Seats in a Lexus ES 300
Guard (safety constraint) Trigger (input)
10
2. Logical Expressions
( (a > b) or G ) and (x < y)
Transitions
Logical
Program Decision Statements
Expressions
Software Specifications
11
2. Logical Expressions
( (a > b) or G ) and (x < y)
Predicate Coverage : Each predicate must be true and
false
◦ ( (a>b) or G ) and (x < y) = True, False
Clause Coverage : Each clause must be true and false
◦ (a > b) = True, False
◦ G = True, False
◦ (x < y) = True, False
Combinatorial Coverage : Various combinations of clauses
◦ Active Clause Coverage: Each clause must determine
the predicate’s result
12
2. Logic – Active Clause Coverage
( (a > b) or G ) and (x < y)
1 T F T
With these
values for G and
2 F F T
(x<y), (a>b)
3 F T T duplicate
determines the
value of the
predicate 4 F F T
5 T T T
6 T T F
13
3. Input Domain Characterization
Describe the input domain of the software
◦ Identify inputs, parameters, or other categorization
◦ Partition each input into finite sets of representative
values
◦ Choose combinations of values
System level
◦ Number of students { 0, 1, >1 }
◦ Level of course { 600, 700, 800 }
◦ Major { swe, cs, isa, infs }
Unit level
◦ Parameters F (int X, int Y)
◦ Possible values X: { <0, 0, 1, 2, >2 }, Y : { 10, 20, 30 }
◦ Tests F (-5, 10), F (0, 20), F (1, 30), F (2, 10), F (5, 20)
14
4. Syntactic Structures
Based on a grammar, or other syntactic definition
Primary example is mutation testing
1. Induce small changes to the program: mutants
2. Find tests that cause mutant programs to fail: killing mutants
3. Failure is defined as different output from the original program
4. Check the output of useful tests on the original program
Example program and mutants
if (x > y)
if (x >= y)
if (x > y) z = x - y;
z = x - y; z = x + y;
else z = x – m;
z = 2 * x; else
z = 2 * x;
15
Example : Jelly Bean Coverage
Flavors : Colors :
1. Lemon 1. Yellow (Lemon, Apricot)
2. Pistachio 2. Green (Pistachio)
3. Cantaloupe 3. Orange (Cantaloupe,
4. Pear Tangerine)
5. Tangerine 4. White (Pear)
6. Apricot
▪ Possible coverage criteria :
1. Taste one jelly bean of each flavor
• Deciding if yellow jelly bean is Lemon or Apricot is a
controllability problem
2. Taste one jelly bean of each color
16
Coverage
Given a set of test requirements TR for coverage
criterion C, a test set T satisfies C coverage if and
only if for every test requirement tr in TR, there is
at least one test t in T such that t satisfies tr
18
Coverage Level
The ratio of the number of test requirements satisfied by
T to the size of TR
19
Two Ways to Use Test Criteria
1. Directly generate test values to satisfy the criterion
◦ Often assumed by the research community
◦ Most obvious way to use criteria
◦ Very hard without automated tools
22
Advantages of Criteria-Based Test Design (5.3)
23
Characteristics of a Good Coverage Criterion
24
Test Coverage Criteria
Traditional software testing is expensive and labor-
intensive
Formal coverage criteria are used to decide which
test inputs to use
More likely that the tester will find problems
Greater assurance that the software is of high
quality and reliability
A goal or stopping rule for testing
Criteria makes testing more efficient and effective
26
Four Roadblocks to Adoption
1. Lack of test education
Microsoft and Google say half their engineers are testers, programmers test half the time
Number of UG CS programs in US that require testing ? 0
Number of MS CS programs in US that require testing ?
0
Number of UG testing classes in the US ? ~50
2. Necessity to change process
Adoption of many test techniques and tools require changes in development process
This is expensive for most software companies
3. Usability of tools
Many testing tools require the user to know the underlying theory to use them
Do we need to know how an internal combustion engine works to drive ?
Do we need to understand parsing and code generation to use a compiler ?
29
Changes in Practice
1. Reorganize test and QA teams to make effective
use of individual abilities
◦ One math-head can support many testers
2. Retrain test and QA teams
◦ Use a process like MDTD
◦ Learn more testing concepts
3. Encourage researchers to embed and isolate
◦ We are very responsive to research grants
4. Get involved in curricular design efforts through
industrial advisory boards
30
Criteria Summary
• Many companies still use “monkey testing”
• A human sits at the keyboard, wiggles the mouse
and bangs the keyboard
• No automation
• Minimal training required
• Some companies automate human-designed tests
• But companies that use both automation and criteria-
based testing
Save money
Find more faults
Build better software
31
31
Structures for Criteria-Based Testing
Four Structures for
Modeling Software