Professional Documents
Culture Documents
6.2 VerificationAndValidationPartII
6.2 VerificationAndValidationPartII
di Milano
Testing
V&V-1
1
Testing
Software
inputs under test outputs
Is output ok
no yes
wrt input?
Fail Success
2 V&V-1
Definitions
3 V&V-1
How to select test sets?
4 V&V-1
The testing process
5$)&2%0)$2
)$+$%&.1- %(.&$(.0
3#$%./.%0&.1-9
5$)&2%0)$2
1 6$-$(0&.1-
)1*(%$2%1'$
,'$-&./.%0&.1-
5$)&2 1/2$"#$%&$' ($)*+&) 2
%0)$)
!"#$%&$'
($)*+&)
5$)&2
($)*+&)
31/&40($2 5$)&2($#1(&
718#0(.)1-
3 *-'$(2&$)&
4
5 V&V-1
Testing vs Analysis
testing: scope-complete:
a few cases of arbitrary size all cases within a small bound
Politecnico
di Milano
Testing activities
V&V-1
7
V&V activities and software artifacts
(the V model)
Actual needs
and constraints Delivered
User acceptance (alpha, beta test)
Package
Review
9 V&V-1
Unit testing and scaffolding
10 V&V-1
Integration Testing
Aimed at exercising
interfaces
modules’ interactions
11 V&V-1
Integration Faults
12 V&V-1
Example from the Apache web server
inctx->ssl = NULL;
inctx->filter_ctx->pssl = NULL;
}
No obvious error, but Apache
leaked memory slowly (in
normal use) or quickly (if
13
exploited for a DOS attack)
V&V-1
Example from the Apache web server
15 V&V-1
How to achieve integration & testing
16 V&V-1
Big Bang integration & testing
17 V&V-1
Incremental integration & testing
18 V&V-1
Some strategies for integration & testing
19 V&V-1
Top down .
Top
20 V&V-1
Top down ..
Top
A stub B stub C
21 V&V-1
Top down ...
Top
A B C
As modules replace
stubs, more functionality
stub X stub Y
is testable
22 V&V-1
Top down ... complete
Top
A B C
23 V&V-1
Bottom Up .
Driver
Starting at the leaves of the
“uses” hierarchy, we never
need stubs
24 V&V-1
Bottom Up ..
25 V&V-1
Bottom Up ...
Driver
A
... an intermediate
module replaces a driver,
and needs its own driver
...
X Y
26 V&V-1
Bottom Up ....
Driver Driver
A B
X Y
27 V&V-1
Bottom Up .....
A B C
28 V&V-1
Bottom Up (complete)
Top
A B C
29 V&V-1
Thread ...
Top
A C
30 V&V-1
Thread ...
Top
A B C
31 V&V-1
Thread ...
Top
A B C
32 V&V-1
Critical Modules
33 V&V-1
Choosing a Strategy
34 V&V-1
System Testing
35 V&V-1
Types of System Testing:
Performance Testing
Purpose
Identify bottlenecks affecting response time, utilization,
throughput
Benchmarking, i.e., establish a performance baseline
and possibly compare it with different versions of the
same product or a different competitive product
Prerequisites
Expected workload
Acceptable performance
Identifying
Inefficient algorithms
Query optimization possibilities
Hardware/Network issues
36 V&V-1
Types of System Testing:
Load Testing
Purpose
Expose bugs such as
memory leaks,
mismanagement of
memory, buffer
overflows
Identify upper limits of
components
How
Increase the load until
threshold
Load the system with the
maximum load it can
operate for a long period
37 V&V-1
Types of System Testing:
Stress Testing
Purpose
Make sure that the system
recovers gracefully after failure
How
Trying to break the system
under test by overwhelming its
resources or by taking
resources away from it
Examples
Double the baseline number
for concurrent users/HTTP
connections
Randomly shut down and
restart ports on the network
switches/routers that connects
servers
38 V&V-1
Politecnico
di Milano
V&V-1
39
The testing procedure
5$)&2%0)$2
)$+$%&.1- %(.&$(.0
3#$%./.%0&.1-9
5$)&2%0)$2
)1*(%$2%1'$
.-#*&26$-$(0&.1-
,'$-&./.%0&.1-
5$)&2%0)$)
1/2$"#$%&$' ($)*+&)
.-#*&) 0-'2
%1(($)#1-'.-6
.-.&.0+ )&0&$
5$)&2%0)$)
!"#$%&$'
($)*+&)
31/&40($2 5$)&2($#1(&
718#0(.)1-
*-'$(2&$)&
5$)&2
($)*+&)
5$)&2$"$%*&.1- $-:.(1-8$-& ;)%0//1+'.-6<
40 V&V-1
The testing procedure
5$)&2%0)$2
)$+$%&.1- %(.&$(.0
3#$%./.%0&.1-9
5$)&2%0)$2
)1*(%$2%1'$
.-#*&26$-$(0&.1-
,'$-&./.%0&.1-
5$)&2%0)$)
1/2$"#$%&$' ($)*+&)
.-#*&) 0-'2
%1(($)#1-'.-6
.-.&.0+ )&0&$
5$)&2%0)$)
!"#$%&$'
($)*+&)
31/&40($2 5$)&2($#1(&
718#0(.)1-
*-'$(2&$)&
5$)&2
($)*+&)
5$)&2$"$%*&.1- $-:.(1-8$-& ;)%0//1+'.-6<
41 V&V-1
A trivial example of software under test
package programLogic;
public class Money {
private int fAmount;
private String fCurrency;
public Money(int amount, String currency) {
fAmount = amount;
fCurrency = currency; }
public int amount() { … }
package testSuite;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import programLogic.Money;
public class MoneyTest {
@Test
public void testAmount() {
Money money1EUR = new Money(100, "EUR");
Money money2EUR = new Money(1000, "EUR");
Money money1$ new Money(111, "$");
assertEquals(100, money1EUR.amount());
assertEquals(1000, money2EUR.amount());
assertEquals(111, money1$.amount());
}
A scaffolding for Money – MoneyTest (2)
@Test
public void testCurrency() {
Money money1EUR = new Money(100, "EUR");
Money money2EUR = new Money(1000, "EUR");
Money money1$ new Money(111, "$");
assertEquals("EUR", money1EUR.currency());
assertEquals("EUR", money2EUR.currency());
assertEquals("$", money1$.currency());
}
@Test
public void testAdd() {
Money money1EUR = new Money(100, "EUR");
Money money2EUR = new Money(1000, "EUR");
Money money1$ new Money(111, "$");
assertTrue("100 EUR + 1000 EUR = 1100 EUR",
money1EUR.add(money2EUR).equals(new Money(1100, "EUR")));
assertNull("100 EUR + 111 $ not possible", money1EUR.add(money1$));
}
…
}
How do we get ready to test execution
phase?
5$)&2%0)$2
)$+$%&.1- %(.&$(.0
3#$%./.%0&.1-9
5$)&2%0)$2
)1*(%$2%1'$
.-#*&26$-$(0&.1-
,'$-&./.%0&.1-
5$)&2%0)$)
1/2$"#$%&$' ($)*+&)
.-#*&) 0-'2
%1(($)#1-'.-6
.-.&.0+ )&0&$
5$)&2%0)$)
!"#$%&$'
($)*+&)
31/&40($2 5$)&2($#1(&
718#0(.)1-
*-'$(2&$)&
5$)&2
($)*+&)
5$)&2$"$%*&.1- $-:.(1-8$-& ;)%0//1+'.-6<
45 V&V-1
Reminder - how to select test sets?
46 V&V-1
Systematic testing:
black-box vs white-box
White-box testing is suitable for unit testing
Covering a small portion of software is possible
47 V&V-1
White-box testing: an example
1 //read i,j,n
2 while (i<n && j<n) { i<n && j<n
F
3 if (i < j)
4 i = i + j; T
5 else if (j < i)
T F
6 j = j + i; i<j
7 else break;
8 } i = i+j T F
j<i
9 //It continues...
j = j+i
48 Testing
White-box testing: edge coverage
1 //read i,j,n
2 while (i<n && j<n) { i<n && j<n
F
3 if (i < j)
4 i = i + j; T
5 else if (j < i)
T F
6 j = j + i; i<j
7 else break;
8 } i = i+j T F
j<i
9 //It continues...
j = j+i
49 Testing
White-box testing: condition coverage
1 //read i,j,n
2 while (i<n && j<n) { i<n && j<n
F
3 if (i < j)
4 i = i + j; T
5 else if (j < i)
T F
6 j = j + i; i<j
7 else break;
8 } i = i+j T F
j<i
9 //It continues...
j = j+i
T
i<n && j<n i< n: T; j<n: F
F i< n: F; j<n: T
50 Testing
White-box testing: path coverage
1 //read i,j,n
2 while (i<n && j<n) { i<n && j<n
F
3 if (i < j)
4 i = i + j; T
5 else if (j < i)
T F
6 j = j + i; i<j
7 else break;
8 } i = i+j T F
j<i
9 //It continues...
j = j+i
51 Testing
A kind of black-box testing:
Model-Based Testing (MBT)
We can use models to devise test cases
The actual behavior of the software under test is
checked against the behavior specified by the model
52 V&V-1
Example of MBT from a state diagram:
online shopping user account
53 V&V-1
How do we identify test cases?
54 V&V-1
Transition coverage
55 V&V-1
MBT and automation
5$)&2%0)$2
)$+$%&.1- %(.&$(.0
3#$%./.%0&.1-9
5$)&2%0)$2
)1*(%$2%1'$
.-#*&26$-$(0&.1-
,'$-&./.%0&.1-
5$)&2%0)$)
1/2$"#$%&$' ($)*+&)
.-#*&) 0-'2
%1(($)#1-'.-6
.-.&.0+ )&0&$
5$)&2%0)$)
!"#$%&$'
($)*+&)
31/&40($2 5$)&2($#1(&
718#0(.)1-
*-'$(2&$)&
5$)&2
($)*+&)
5$)&2$"$%*&.1- $-:.(1-8$-& ;)%0//1+'.-6<
V&V-1
Random/Statistical Testing
,'$-&./.%0&.1-
5$)&2%0)$)
1/2$"#$%&$' ($)*+&)
.-#*&) 0-'2
%1(($)#1-'.-6
.-.&.0+ )&0&$
5$)&2%0)$)
!"#$%&$'
($)*+&)
31/&40($2 5$)&2($#1(&
718#0(.)1-
*-'$(2&$)&
5$)&2
($)*+&)
5$)&2$"$%*&.1- $-:.(1-8$-& ;)%0//1+'.-6<
V&V-1
Random testing: strengths and weaknesses
+ -
Completely automatic Input validity
Can be very extensive May find the same bug
Unbiased over and over
Allows testers to identify May identify several
completely unforeseen minor bugs not relevant
issues to most of the use cases
for the software
May result in frustration
58 V&V-1
Capture & reply testing
5$)&2
%0)$)
A0-*0+ =*&180&$'
$"$%*&.1- $"$%*&.1- ;0/&$( /.()&280-*0+ $"$%*&.1-<
5$)&2
($)*+&)
31/&40($2 5$)&2($#1(&
>(0%+$
*-'$(2&$)&
Pre−Post
Transition−Based
Paradigm History−Based The model is the main input
Functional
Operational to the test generation
Structural Model Coverage
Data Coverage
Test Selection Requirements Coverage
Test Case Specifications
Criteria Random&Stochastic
Test Fault−Based
Generation Manual
Random generation
Graph search algorithms
Technology Model−checking
Symbolic execution
Theorem proving
Test
Manual vs automated and
Execution On/Offline Online / Offline
integrated with test generation
60 V&V-1
e software Pre−Post
Transition−Based
n the test Pseudo random
Paradigm
numbers
History−Based
Functional
Operational
SOFTWARE
62 V&V-1
Politecnico
di Milano
References
V&V-1
63
References
64 V&V-1
References
65 V&V-1