Professional Documents
Culture Documents
UNIT-1 Software Testing
UNIT-1 Software Testing
Structured programming
Improves computer program quality
Allows other programmers to easily read and
modify code
Each program module has one beginning and
one ending
Three programming constructs (sequence,
decision, repetition)
SOFTWARE ENGINEERI
NG
SOFTWARE ENGINEERI
NG
Program testing
Can reveal the presence of errors NOT their
absence
A successful test is a test which discovers one
or more errors
The only validation technique for non-functional
requirements
Should be used in conjunction with static
verification to provide full V&V coverage
SOFTWARE ENGINEERI
NG
Testing Principles
All tests should be traceable to customer
requirements.
Tests should be planned long before testing
begins
Testing should begin in the small & progress
toward in the large
Exhaustive testing is not possible.
To be most effective, testing should be
conducted by an independent third party
SOFTWARE ENGINEERI
NG
Testing priorities
Only exhaustive testing can show a program is
free from defects. However, exhaustive testing
is impossible
Tests should exercise a system's capabilities
rather than its components
Testing old capabilities is more important than
testing new capabilities
Testing typical situations is more important than
boundary value cases
SOFTWARE ENGINEERI
NG
Testsing 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
SOFTWARE ENGINEERI
NG
SOFTWARE ENGINEERI
NG
Levels of testing
Unit testing
Integration testing
System testing
Acceptance testing
SOFTWARE ENGINEERI
NG
Test Plane
SOFTWARE ENGINEERI
NG
Component
testing
System
testing
SOFTWARE ENGINEERI
NG
Acceptance
testing
Testing stages
Component or unit testing
Individual components are tested independently;
Components may be functions or objects or coherent
groupings of these entities.
System testing
Testing of the system as a whole. Testing of emergent
properties is particularly important.
Acceptance testing
Testing with customer data to check that the system
meets the customers needs.
SOFTWARE ENGINEERI
NG
Types of testing
Defect testing
Tests designed to discover system defects.
A successful defect test is one which reveals
the presence of defects in a system.
Statistical testing
tests designed to reflect the frequence of user
inputs. Used for reliability estimation.
SOFTWARE ENGINEERI
NG
Integration testing
Testing of groups of components integrated to create
a system or sub-system
The responsibility of an independent testing team
Tests are based on a system specification
SOFTWARE ENGINEERI
NG
Testing phases
Component
testing
Integration
testing
Softwaredeveloper
Independenttestingteam
SOFTWARE ENGINEERI
NG
Testing phases
Requirements
specification
System
specification
System
integration
test plan
Acceptance
test plan
Service
System
design
Acceptance
test
Detailed
design
Sub-system
integration
test plan
System
integration test
Sub-system
integration test
SOFTWARE ENGINEERI
NG
Module and
unit code
and test
Black-box testing
An approach to testing where the program
is considered as a black-box
The program test cases are based on the
system specification
Test planning can begin early in the
software process
SOFTWARE ENGINEERI
NG
Black-box testing
Inputtestdata
Inputscausing
anomalous
behaviour
System
Outputtestresults
Oe
SOFTWARE ENGINEERI
NG
Outputswhich reveal
thepresenceof
defects
Equivalence partitioning
Input data and output results often fall into
different classes where all members of a
class are related
Each of these classes is an equivalence
partition where the program behaves in an
equivalent way for each class member
Test cases should be chosen from each
partition
SOFTWARE ENGINEERI
NG
Equivalence partitioning
Invali d in pu ts
Vali d in pu ts
Sy stem
Ou tput s
SOFTWARE ENGINEERI
NG
Equivalence partitioning
Partition system inputs and outputs into
equivalence sets
If input is a 5-digit integer between 10,000 and
99,999,
equivalence partitions are <10,000, 10,000-99, 999
and >
10, 000
Equivalence partitions
3
Lessthan4
11
10
Between 4and10
Morethan10
Numberof inputvalues
9999
10000
Less than10000
50000
100000
99999
Between 10000and99999
Inputvalues
SOFTWARE ENGINEERI
NG
Morethan99999
Inputsequence(T)
17
17
17,29,21,23
41,18,9,31,30,16,45
17,18,21,23,29,41,38
21,23,29,33,38
Element
Insequence
Notinsequence
Firstelementinsequence
Lastelementinsequence
Middleelementinsequence
Notinsequence
Key(Key)
17
0
17
45
23
25
Output(Found, L)
true,1
false,??
true,1
true,7
true,4
false,??
SOFTWARE ENGINEERI
NG
Elements<Mid
Elements>Mid
Midpoint
SOFTWARE ENGINEERI
NG
BVA: continued
This leads to 3 test inputs:
X=0, X=-20, and X=14.
Note that the values -20 and 14 are on either side of
the boundary and are chosen arbitrarily.
BVA: continued
Now suppose that a program takes two
integers X and Y and that x1<=X<=x2 and
y1<=Y<=y2.
In this case the four sides of the rectangle
represent the boundary.
SOFTWARE ENGINEERI
NG
BVA: continued
For example, suppose that a program
takes a string S and an integer X as
inputs. The BVA can be done on any type
of data.
constraints on inputs are:
length(S)<=100 and a<=X<=b
SOFTWARE ENGINEERI
NG
BVA: continued
Just as we applied BVA to input data, we
can apply it to output data.
Doing so gives us equivalence classes for
the output domain.
We then try to find test inputs that will
cover each output equivalence class.
SOFTWARE ENGINEERI
NG
SOFTWARE ENGINEERI
NG
White-box testing
Testdata
Tests
Derives
Component
code
SOFTWARE ENGINEERI
NG
Test
outputs
Path testing
The objective of path testing is to ensure that the
set of test cases is such that each path through
the program is executed at least once
The starting point for path testing is a program
flow graph that shows nodes representing
program decisions and arcs representing the
flow of control
Statements with conditions are therefore nodes
in the flow graph
SOFTWARE ENGINEERI
NG
SOFTWARE ENGINEERI
NG
Contd..
Complexity is computed in one of three ways:
The no. of regions of the flowgraph corrospond
to the cyclomatic complexity.
cyclomatic complexity, V(G), for a flow graph ,
G , is defined as
v(G)= E+N-2
E is the no. of edges, N is the no. of nodes
V(G) = P+1
P is the no. of predicate nodes
SOFTWARE ENGINEERI
NG
Cyclomatic complexity
The number of tests to test all control
statements equals the cyclomatic complexity
Cyclomatic complexity equals number of
conditions in a program
Useful if used with care. Does not imply
adequacy of testing.
Although all paths are executed, all
combinations of paths are not executed
SOFTWARE ENGINEERI
NG
bottom>top
whilebottom<=top
2
if(elemArray[mid]==key
8
5
(if(elemArray[mid]<key
6
9
7
SOFTWARE ENGINEERI
NG
Independent paths
1, 2, 3, 8, 9
1, 2, 3, 4, 6, 7, 2
1, 2, 3, 4, 5, 7, 2
1, 2, 3, 4, 6, 7, 2, 8, 9
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
SOFTWARE ENGINEERI
NG
Contd
Cyclomatic complexity for the above diagram
1. The flow graph has 4 regions.
2. V(G)= 11-9+2
=4
3. V(G)=3+1
=4
SOFTWARE ENGINEERI
NG
Key points
Test parts of a system which are commonly used
rather than those which are rarely executed
Equivalence partitions are sets of test cases
where the program should behave in an
equivalent way
Black-box testing is based on the system
specification
Structural testing identifies test cases which
cause all paths through the program to be
executed
SOFTWARE ENGINEERI
NG
PROCEDURE
UNDERTEST
STUB
CALL
DRIVER
CALL
ACCESSTONONLOCALVARIABLES
SOFTWARE ENGINEERI
NG
Integration testing
Tests complete systems or subsystems
composed of integrated components
Integration testing should be black-box
testing with tests derived from the
specification
Main difficulty is localising errors
Incremental integration testing reduces
this problem
SOFTWARE ENGINEERI
NG
Bottom-up testing
Integrate individual components in levels until
the complete system is created
T1
T1
A
T1
T2
T2
T2
T3
T3
C
T4
T3
C
T4
T5
D
Testsequence
1
Testsequence
2
SOFTWARE ENGINEERI
NG
Testsequence
3
Top-down testing
Level1
Testing
sequence
Level2
Level1
Level2
Level2
Level2
stubs
Level3
stubs
SOFTWARE ENGINEERI
NG
...
Level2
Bottom-up testing
Test
drivers
LevelN
Test
drivers
LevelN
LevelN1
Le velN
LevelN1
LevelN
LevelN
LevelN1
SOFTWARE ENGINEERI
NG
Testing
sequence
Stress testing
Exercises the system beyond its maximum
design load. Stressing the system often causes
defects to come to light
Stressing the system test failure behaviour..
Systems should not fail catastrophically. Stress
testing checks for unacceptable loss of service
or data
Particularly relevant to distributed systems
which can exhibit severe degradation as a
network becomes overloaded
SOFTWARE ENGINEERI
NG
Acceptance test
Regression test
Check against
requirements
specifications
Performed by
development test group
Performed by
development group
Guards against
unintended changes
SOFTWARE ENGINEERI
NG
System testing
Can be considered a final step in integration
testing
A check of consistency between the software
system and its specification
Encompasses system wide properties against a
system specification
Test
results
Locate
error
Test
cases
Specification
Design
errorrepair
Repair
error
SOFTWARE ENGINEERI
NG
Retest
program
Objectives
To introduce software verification and
validation and to discuss the distinction
between them
To describe the program inspection
process and its role in V & V
To explain static analysis as a verification
technique
To describe the Cleanroom software
development process
SOFTWARE ENGINEERI
NG
Verification vs validation
Verification:
"Are we building the product right"
The software should conform to its
specification
Validation:
"Are we building the right product"
The software should do what the user
really requires
SOFTWARE ENGINEERI
NG
SOFTWARE ENGINEERI
NG
Requirements
specification
Highlevel
design
Formal
specification
Detailed
design
Program
Dynamic
validation
Prototype
SOFTWARE ENGINEERI
NG