Functional Testing
Functional Testing
Functional Testing
Software Engineering
Andreas Zeller Saarland University
Testing Tactics
Functional
Structural
black box
white box
Why Functional?
Functional
Structural
black box
white box
Why Functional?
Functional
Structural
black box
white box
A Challenge
class Roots {
// Solve ax2 + bx + c = 0
public roots(double a, double b, double c)
{ }
// Result: values for x
double root_one, root_two;
}
assuming a, b, c, were 32-bit integers, wed have (232)3 1028 legal inputs
with 1.000.000.000.000 tests/s, we would still require 2.5 billion years
10
11
12
A Challenge
class Roots {
// Solve ax2 + bx + c = 0
public roots(double a, double b, double c)
{ }
// Result: values for x
double root_one, root_two;
}
assuming a, b, c, were 32-bit integers, wed have (232)3 1028 legal inputs
with 1.000.000.000.000 tests/s, we would still require 2.5 billion years
13
Random Testing
Pick possible inputs uniformly
Avoids designer bias
A real problem: The test designer can make the same logical
mistakes and bad assumptions as the program designer
(especially if they are the same person)
15
identify
Independently
testable feature
identify
derive
Representative
values
Model
derive
generate
Test case
specifications
Test case
16
Testable Features
Functional
specification
identify
Independently
testable feature
into
Decompose systemRepresentative
identify
derive
Model
values
derive
generate
Test case
case testing, ITFs are exposed
ForTestsystem
specifications
17
Testable Fatures
class Roots {
// Solve ax2 + bx + c = 0
public roots(double a, double b, double c)
{ }
// Result: values for x
double root_one, root_two;
}
Ask
audience
Testable Fatures
Consider a multi-function
calculator
Ask
audience
19
Testable Features
Functional
specification
identify
Independently
testable feature
identify
derive
Representative
values
Model
derive
generate
Test case
Test case
specifications
20
Representative Values
Functional
Try to select
specification
identify
Independently
inputs
testable feature
that are especially
identify
derive
valuable
Usually by
Representative
values
Model
choosing
representatives of equivalence derive
classes that
generate
are apt to fail often or not Test
at allcase
Test case
specifications
21
Needles in a Haystack
To find needles,
look systematically
22
No failure
23
Equivalence Partitioning
Input condition
Equivalence classes
range
specific value
member of a set
boolean
24
Boundary Analysis
Possible test case
Output:
Ask
list of cities audience
What are
representative
values to test?
26
2. with 1 city
as output
3. with many cities
as output
27
6. 6 characters
(6 is boundary value)
Gutjahrs Hypothesis
Partition testing
is more effective
than random testing.
30
Representative Values
identify
Functional
specification
Independently
testable feature
identify
derive
Representative
values
Model
derive
generate
Test case
specifications
Test case
31
Model-Based Testing
identify
Functional
specification
Independently
testable feature
derive
Representative
as
Models typically come
values
finite state machines and
decision structures
Test case
Model
derive
generate
Test case
specifications
32
Finite
State
Machine
33
34
Coverage Criteria
Path coverage: Tests cover every path
State coverage: Every node is executed
Transition coverage: Every edge is executed
Not feasible in practice due to infinite number of paths
35
Transition
Coverage
36
State-based Testing
Protocols (e.g., network communication)
GUIs (sequences of interactions)
Objects (methods and states)
37
empty
acct
open
set up
acct
setup Accnt
deposit
(initial)
Account states
deposit
working
acct
balance
credit
accntInfo
withdraw
withdrawal
(final)
dead
acct
nonworking
acct
close
38
Figure 14.3 State diagram for Account class (adapted from [KIR94])
Decision Tables
Education
Individual
Education account
Out
Edu
Special
No
Special Tier1 Special Tier2 Special
discount price discount price discount price discount Price
39
Condition Coverage
Basic criterion: Test every column
Compound criterion: Test every combination
Modified condition decision criterion (MCDC):
Dont care entries () can take arbitrary values
40
MCDC Criterion
Education
Individual
Education account
T
F
Edu
Special
No
Special Tier1 Special Tier2 Special
discount price discount price discount price discount Price
Out
41
MCDC Criterion
Education
Individual
Education account
TF
Out
Edu
Special
No
Special Tier1 Special Tier2 Special
discount price discount price discount price discount Price
42
MCDC Criterion
Education
Individual
Education account
T
F
Edu
Special
No
Special Tier1 Special Tier2 Special
discount price discount price discount price discount Price
Out
43
MCDC Criterion
Education
Individual
Education account
T
F
Out
Edu
Special
No
Special Tier1 Special Tier2 Special
discount price discount price discount price discount Price
44
Weyukers Hypothesis
45
46
Paretos Law
47
Model-Based Testing
Functional
specification
identify
Independently
testable feature
identify
derive
Representative
values
Model
derive
generate
Test case
Test case
specifications
48
specification
testable feature
Now:
need
to
take
care
of
combinations
Input
values enumerated in previous
step
Functional
Independently
identify
derive
Model
derive
Test case
specifications
49
Combinatorial Testing
IIS
Server
Windows
OS
Linux
Apache
MySQL
Oracle
Database
50
Combinatorial Testing
Eliminate invalid combinations
Cover all pairs of combinations
Combinations typically generated
IIS only runs on Windows, for example
automatically
51
Pairwise Testing
IIS
Windows
Apache
IIS
Linux
Apache
MySQL Oracle
IIS
Linux
MySQL Oracle
Windows
Apache
Windows
IIS
Linux
Windows
Apache
MySQL Oracle
Linux
MySQL Oracle
52
Testing environment
Millions of configurations
Testing on dozens of different machines
All needed to find & reproduce problems
53
identify
Independently
testable feature
identify
derive
Representative
values
Model
derive
generate
Test case
Test case
specifications
54
identify
Independently
testable feature
derive
Model
derive
generate
Test case
specifications
Test case
55
Unit Tests
Directly access units (= classes, modules,
components) at their programming
interfaces
identify
Independently
testable feature
identify
derive
Representative
values
Model
derive
generate
Test case
Test case
specifications
57
identify
Independently
testable feature
identify
derive
Representative
values
Model
derive
generate
Test case
Test case
specifications
58
Summary
59