Software Testing: ©ian Sommerville 2004
Software Testing: ©ian Sommerville 2004
T
e st
T
e st
cases
da
ta
Design
Pr
epar
e R
u
o
g
cases
da r
aT
e
r
tes
n
C
m
tawith
ta st
eT
e
su
rt
es
toop
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 8
Testing policies
● Only exhaustive testing can show a program is free
from defects. However, exhaustive testing is
impossible,
● Testing policies define the approach to be used in
selecting system tests:
• All functions accessed through menus should be tested;
• Combinations of functions accessed through the same
menu should be tested;
• Where user input is required, all functions must be tested
with correct and incorrect input.
T2
T2
B
BT3
CT3
C
T4T
T
T
est
T D
est
TT
ese
s
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 12
Testing approaches
● Architectural validation
• Top-down integration testing is better at discovering
errors in the system architecture.
● System demonstration
• Top-down integration testing allows a limited
demonstration at an early stage in the development.
● Test implementation
• Often easier with bottom-up integration testing.
● Test observation
• Problems with both approaches. Extra code may be
required to observe tests.
S
yste
Ou
hic
ev
the
es a
Outpu
esult
Oede
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 15
Testing guidelines
● Testing guidelines are hints for the testing
team to help them choose tests that will reveal
defects in the system
• Choose inputs that force the system to generate
all error messages;
• Design inputs that cause buffers to overflow;
• Repeat the same input or input series several
times;
• Force invalid outputs to be generated;
• Force computation results to be too large or too
small.
A student in Scotland is studying American History and has been asked to write a paper
on ÔFrontier mentality in the American West from 1840 to 1880Õ.To do this, she needs to
find sources from a range of libraries. She logs on to the LIBSYS system and uses the
search facility to discover if she can access original documents from that time. She
discovers sources in various US university libraries and downloads copies of some of
these. However, for one document, she needs to have confirmation from her university
that she is a genuine student and that use is for non-commercial purposes. The student
then uses the facility in LIBSYS that can request such permission and registers her
request. If granted, the document will be downloaded to the registered libraryÕs server
and printed for her. She receives a message from LIBSYS telling her that she will receive
an e-mail message when the printed document is available for collection.
ackno
repo
t sum
()
send
t)
reply
t)
ackno
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 20
Performance testing
● Part of release testing may involve testing
the emergent properties of a system, such
as performance and reliability.
● Performance tests usually involve planning a
series of tests where the load is steadily
increased until the system performance
becomes unacceptable.
ACB
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 28
Interface types
● Parameter interfaces
• Data passed from one procedure to another.
● Shared memory interfaces
• Block of memory is shared between procedures or
functions.
● Procedural interfaces
• Sub-system encapsulates a set of procedures to be
called by other sub-systems.
● Message passing interfaces
• Sub-systems request services from other sub-system.s
In
v
aSlid
V
a lid
yste in
©Ian Sommerville 2004
Outp
Software Engineering, 7th edition. Chapter 23 Slide 37
3
471
0
Less
Betw
een
0
Mo
e
0 t
Equivalence partitions
Numb
alue
inpu
9999
1
05
01
0 0
000
999
00
Less
0000
Betw
een
000
Mo
Inpute
alues t
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 38
Search routine specification
Pre-condition
-- the sequence has at least one element
T’FIRST <= T’LAST
Post-condition
-- the element is found and is referenced by L
( Found and T (L) = Key)
or
-- the element is not in the array
( not Found and
not (exists i, T’FIRST >= i <= T’LAST, T (i) = Key ))
the array.
● Inputs where the key element is not a
member of the array.
codT
e
ou
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 44
Binary search - equiv. partitions
● Pre-conditions satisfied, key element in array.
● Pre-conditions satisfied, key element not in
array.
● Pre-conditions unsatisfied, key element in array.
● Pre-conditions unsatisfied, key element not in array.
● Input array has a single value.
● Input array has an even number of values.
● Input array has an odd number of values.
Elem
Ele
Mid
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 46
Binary search - test cases
2
3
4
bottom
5
6while b
7elemA
1
elemArr
elem
elemA
[mid]
8 1
213 =
19
41
0
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 49
Independent paths
● 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14
● 1, 2, 3, 4, 5, 14
● 1, 2, 3, 4, 5, 6, 7, 11, 12, 5, …
● 1, 2, 3, 4, 6, 7, 2, 11, 13, 5, …
● Test cases should be derived so that all of
these paths are executed
● A dynamic program analyser may be used to
check that paths have been executed
d
Dynam
anal
Ex Pr
o
g
r
a
yserm
T
e T
e
esul
beingst
pr
edist
r
recution
et Sim
ula
tor
porFile
com
R
e
tTe
po
es
gen
aor s
rt p
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 52
Testing workbench adaptation
● Scripts may be developed for user interface
simulators and patterns for test data
generators.
● Test outputs may have to be prepared
manually for comparison.
● Special-purpose file comparators may be
developed.