01-Functional Testing PDF
01-Functional Testing PDF
Software Engineering
Andreas Zeller • Saarland University
3
If the program is not the base, then what
is? Simple: itʼs the specification.
Why Functional?
Functional Structural
“black box” “white box”
9
Note that in 900 million years, due to
increase of the luminosity of the sun,
Life Cycle of the Sun CO2 levels will be toxic for plants; in 1.9
billion years, surface water will have
evaporated (source: Wikipedia on
“Earth”)
10
11
12
A Challenge
class Roots {
// Solve ax2 + bx + c = 0
public roots(double a, double b, double c)
{ … }
14
15
The main steps of a systematic
approach to functional program testing
Systematic Functional Testing (from Pezze + Young, “Software Testing
and Analysis”, Chapter 10)
identify
Functional Independently
specification testable feature
identify derive
Representative
Model
values
derive
generate
Test case
Test case
specifications
16
Testable Features
identify
Functional Independently
specification testable feature
• Decompose systemRepresentative
into
identify derive
class Roots {
// Solve ax2 + bx + c = 0
public roots(double a, double b, double c)
{ … }
identify derive
Representative
Model
values
derive
generate
Test case
Test case
specifications
20
21
Needles in a Haystack
• To find needles,
look systematically
• We need to find out
what makes needles special
22
24
How do we choose representatives rom
equivalence classes? A greater number
Boundary Analysis of errors occurs at the boundaries of an
equivalence class rather than at the
“center”. Therefore, we specifically look
Possible test case for values that are at the boundaries –
both of the input domain as well as at
the output.
26
2. with 1 city
as output
3. with many cities
as output
27
(from Pezze + Young, “Software Testing
and Analysis”, Chapter 10)
Invalid ZIP Codes
4. empty input
5. 1–4 characters
(4 is boundary value)
6. 6 characters
(6 is boundary value)
29
Partition testing
is more effective
than random testing.
30
The main steps of a systematic
approach to functional program testing
Representative Values (from Pezze + Young, “Software Testing
and Analysis”, Chapter 10)
identify
Functional Independently
specification testable feature
identify derive
Representative
Model
values
derive
generate
Test case
Test case
specifications
31
32
0
As an example, consider these steps
modeling a product maintenance
process…
(from Pezze + Young, “Software Testing
1 2 and Analysis”, Chapter 14)
3
4 5 6
Finite
State 7 8
Machine
9
33
…based on these (informal)
requirements
(from Pezze + Young, “Software Testing
and Analysis”, Chapter 14)
34
Coverage Criteria
35
0
With five test cases (one color each), we
can achieve transition coverage
(from Pezze + Young, “Software Testing
and Analysis”, Chapter 14)
1 2
3
4 5 6
Transition
Coverage 7 8
36
Finite state machines can be used to
model for a large variety of behaviors –
State-based Testing and thus serve as a base for testing.
37
Account states
– a practitionerʼs approach”, Chapter 14)
deposit
working
acct
balance
credit withdraw
accntInfo
withdrawal
(final)
dead nonworking
acct close acct
38
Figure 14.3 State diagram for Account class (adapted from [KIR94])
39
Condition Coverage
• Basic criterion: Test every column
“Don’t care” entries (–) can take arbitrary values
41
Education account T T F F F F F F
Current purchase >
Threshold 1 – – F F T T – –
Current purchase >
Threshold 2 – – – – F F T T
Special price <
scheduled price TF T F T – – – –
Special price <
Tier 1 – – – – F T – –
Special price <
Tier 2 – – – – – – F T
Edu Special No Special Tier 1 Special Tier 2 Special
Out discount price discount price discount price discount Price
42
MCDC Criterion
Education Individual
Education account T F
T F F F F F F
Current purchase >
Threshold 1 – – F F T T – –
Current purchase >
Threshold 2 – – – – F F T T
Special price <
scheduled price F T F T – – – –
Special price <
Tier 1 – – – – F T – –
Special price <
Tier 2 – – – – – – F T
Edu Special No Special Tier 1 Special Tier 2 Special
Out discount price discount price discount price discount Price
43
Education account T T F F F F F F
Current purchase >
Threshold 1 – – F F T T – –
Current purchase >
Threshold 2 – – – – F F T T
Special price <
scheduled price F F
T F T – – – –
Special price <
Tier 1 – – – – F T – –
Special price <
Tier 2 – – – – – – F T
Edu Special No Special Tier 1 Special Tier 2 Special
Out discount price discount price discount price discount Price
44
45
To decide where to put most effort in
testing, one can also examine the past –
Learning from the past i.e., where did most defects occur in the
past. The above picture shows the
distribution of security vulnerabilities in
Firefox – the redder a rectangle, the
more vulnerabilities, and therefore a
likely candidate for intensive testing.
The group of Andreas Zeller at Saarland
University researches how to mine such
information automatically and how to
predict future defects.
46
47
identify derive
Representative
Model
values
derive
generate
Test case
Test case
specifications
48
The main steps of a systematic
approach to functional program testing
Deriving Test Case Specs (from Pezze + Young, “Software Testing
and Analysis”, Chapter 10)
identify
• specification
Input values enumerated in previous
Functional step
Independently
testable feature
• Now: need to take care of combinations
identify derive
• Typically, one Representative
uses models and values
Model
representative
values to generate derive
test cases generate
Test case
Test case
specifications
49
IIS Windows
Server OS
Apache Linux
MySQL Oracle
Database 50
Combinatorial Testing
51
Pairwise testing means to cover every
single pair of configurations
Pairwise Testing
IIS Windows IIS Windows
52
• Millions of configurations
• Testing on dozens of different machines
• All needed to find & reproduce problems
53
identify derive
Representative
Model
values
derive
generate
Test case
Test case
specifications
54
The main steps of a systematic
approach to functional program testing
Deriving Test Cases (from Pezze + Young, “Software Testing
and Analysis”, Chapter 10)
identify
Functional Independently
specification testable feature
• Implement test cases in code identify derive
• Requires building scaffolding –
Representative
i.e., drivers and stubs values Model
derive
generate
Test case
Test case
specifications
55
56
identify derive
Representative
Model
values
derive
generate
Test case
Test case
specifications
57
The main steps of a systematic
approach to functional program testing
Systematic Functional Testing (from Pezze + Young, “Software Testing
and Analysis”, Chapter 10)
identify
Functional Independently
specification testable feature
identify derive
Representative
Model
values
derive
generate
Test case
Test case
specifications
58
Summary
59