Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
John Morris
Computer Science/
Electrical and Computer Engineering
28 Dec 2015
Terms
Validation
Ensuring that the specification is correct
Determine that the software to be built is actually
what the user wants!
Verification
Ensuring that the software runs correctly
28 Dec 2015
Validation or Verification?
Validation
Building the right software
Make sure its what the user wants
Verification
Building the software right
Make sure it works
Specifications
Functional
Define actions and operations of system
eg
Each transaction shall be stored in a database
GST at the current rate is applied to invoice
28 Dec 2015
Specifications
Functional
Define actions and operations of system
Can be verified by software tests
Non-functional
Performance
eg
Searches will take <2 seconds
Messages will be compressed by 60%
Usability
eg
An trained monkey shall be able to run this software
Specifications
Functional
Define actions and operations of system
Can be verified by software tests
Non-functional
Performance
eg
Searches will take <2 seconds
Messages will be compressed by 60%
Usability
eg
An trained monkey shall be able to run this software
Testing
Aim
Locate and repair defects
Axiom
28 Dec 2015
Testing
The alternative?
Formal verification
Uses formal logic to prove that software is correct
Currently:
Prohibitively expensive
Little automated support
Mainly manual techniques
Error prone
Testing - Motivation
Definitely the least glamorous part of software
development
Possibly the most expensive!
If not carried out thoroughly!
Estimates of the economic cost of software failure
produce astronomic numbers
US: $59.5 billion in 2002
http://www.nist.gov/public_affairs/releases/n02-10.htm
28 Dec 2015
A bug in the flight software for the Mariner 1 causes the rocket to divert
from its intended path on launch. Mission control destroys the rocket over
the Atlantic Ocean. The investigation into the accident discovers that a
formula written on paper in pencil was improperly transcribed into
computer code, causing the computer to miscalculate the rocket's trajectory.
28 Dec 2015
10
28 Dec 2015
11
12
More stories
http://www.wired.com/software/coolapps/news/2005/11/69355
or
Software testing failures in Google!
28 Dec 2015
13
Approach
1.
2.
3.
4.
Codings finished
Run a few tests
System passes
Release
Result: Disaster
Inadequate design or poor coding
produced many timebombs in the system!
28 Dec 2015
14
Approach
1.
2.
3.
4.
Codings finished
Run a few tests
System passes
Release
15
28 Dec 2015
16
17
28 Dec 2015
18
Testing strategies
Exhaustive testing - Try all possible inputs
Nave
Simple (easy to implement)
Easy to justify and
Argue for completeness!
28 Dec 2015
19
Exhaustive Testing
Inefficient, naive?
Never forget the KISS principle
An automated test system can do a very large
numbers of tests in a reasonable time
and do them while youre designing the next test!
Analysis needed is trivial
whereas
Analysis for a more efficient test regime may be
quite complex and error-prone
Its easy to convince someone that an
exhaustively tested system is reliable
28 Dec 2015
20
Efficient testing
Many tests are redundant
In the adder example, most tests are equivalent
They dont exercise any new part of the underlying
circuit!
For example, you might argue that
all additions of +ve numbers without overflow are equivalent
Addition of 0 to a +ve number is the same for all +ve numbers
Similarly for 0 + -ve number
etc
28 Dec 2015
21
Equivalence Classes
Key concept:
Only one representative of each class needs
to be tested!
All other tests of inputs in the same equivalence
class just repeat the first one!
Dramatic reduction in total number of tests
No loss of coverage or satisfaction that tests are
complete
28 Dec 2015
22
Adder example
Test
+ve, no
overflow
20
40
60
+ve, overflow
2^31
2^20
overflow
+ve, 0
34
34
-ve, no overflow
-100
-30
-130
-ve, 0
-30
30
-ve, overflow
-2^31
-2^31
underflow
Result 0
-30
30
?
?
23
28 Dec 2015
24
a~a
if a ~ b and b ~ c, then a ~ c
if a ~ b then b ~ a
25
26
27
28
White Box
Code is available and can be analyzed
Equivalence classes are derived from rules in the
specification and the code
28 Dec 2015
29
28 Dec 2015
30
31
28 Dec 2015
5 6
15 16
29
32
However
An experienced tester knows that a very common
error is writing
< for or
> for
or vice versa
So include class limits too!
3
28 Dec 2015
5 6
15 16
29
33
Unity
Identity under multiplication: x 1 = x
Illegal values
Should raise exceptions or return errors
Read the specification to determine behaviour!
-5
-1 0 1
28 Dec 2015
5 6
15 16
29
999
34
-5
-1 0 1
28 Dec 2015
5 6
15 16
29
999
35
-5
-1 0 1
28 Dec 2015
5 6
15 16
29
999
36
eg No items in a report
does theprogrammers
user want a confirming
Experienced
know that
report anyway? its a very common source of error!
37
38
28 Dec 2015
39
28 Dec 2015
40
28 Dec 2015
nodes
edges
41
Statement Coverage
Statement Coverage requires that
each statement is executed at least once
Simplest form of logic coverage
Also known as Node Coverage
What is the minimum number of test cases
required to achieve statement coverage for
the program segment given next?
28 Dec 2015
42
28 Dec 2015
nodes
edges
43
Branch coverage
Branch Coverage requires that each branch
will have been traversed, and that every
program entry point will have been taken, at
least once
Also known as Edge Coverage
28 Dec 2015
44
45
46
28 Dec 2015
47