Professional Documents
Culture Documents
CS-321
Instructor: Nadeem Sarwar
University Of Gujrat Sialkot Sub Campus
Software Testing
requirements conformance
performance
an indication
of quality
Who Tests the Software?
loop < 20 X
14
There are 10 possible paths! If we execute one
test per millisecond, it would take 3,170 years to
test this program!!
Selective Testing
Selected path
loop < 20 X
What are the steps?
Software is tested from two different
perspectives
Internal program logic is exercised using
“white box” test case design techniques
Software requirements are exercised using
“black box” test case design techniques.
… cont’d
There are two ways of testing a product
Black-Box testing
tests are conducted at the software interface
Checks whether inputs, outputs and functions are
properly working
It pays little regard to the internal logical structure
White-Box testing
Closely examines the procedural details
Logical paths are thoroughly tested
Testing of Engineered Product
Black-box testing
Knowing the specified function that a product has been
designed to perform, tests can be conducted that
demonstrate each function is fully operational while at
the same time searching for errors in each function
White-box testing
Knowing the internal workings of a product, tests can
be conducted to ensure that “all gears mesh,” that is,
internal operations are performed according to
specifications and all internal components have been
adequately exercised.
White-Box Testing
White-Box Testing (or Glass Box Testing)
requirements
output
input events
Black Box Testing
Internal working taken as perfect
Focus on interface
Internal working of software being tested is
not known to the tester
conformance to requirements
Also known as
Functional Testing
Why White Box ?
Why white box when black box done
Logic errors and incorrect assumptions.
assumptions about execution paths may be incorrect,
and so make design errors. White box testing can find
these errors.
Software Testing
Strategies
Software Testing Strategy
What is it ?
Designing effective test cases is important, but also is the strategy
you use to execute them
Why is it important ?
oTesting often takes more project effort than any other
software engineering activity
oIf it is conducted haphazardly, time is wasted, unnecessary
effort is expended, and even worse, errors sneak through
undetected
oItwould therefore seem reasonable to establish a
SYSTEMATIC STRATEGY for testing software
Testing
• Testing begins at the module level and works outward
toward the integration of the entire computer-based
system.
• Different testing techniques are appropriate at different
points in time.
• Testing is conducted by the developer or tester of the
software and (for large projects) an independent test
group.
• Testing and debugging are different activities, but
debugging must be accommodated in any testing
strategy.
Verification and Validation
• Verification – are we building the product right ?
– refers to the set of activities that ensure that
software correctly implements a specific function.
“Are we
building the
product right?”
Validation
“Are we
building the
right product?”
Testing Strategy
system
test validation
test
Unit Testing
module
to be
tested
results
software
engineer
test cases
Unit Testing
It is a verification effort on the smallest unit of the
software design – the software component or module
The unit test is white-box oriented
The steps can be conducted in parallel for multiple
modules
Unit Testing
module
to be
tested
interface
local data structures
boundary conditions
independent paths
error handling paths
test cases
Unit Test Procedures
Unit testing is normally considered as an adjunct to the
coding step
Because a component is a stand-alone program, drive and/or
stub software must be developed
Stub::
Stub
Driver::
Driver ItItserves
servestotoreplace
replacemodules
modulesthat
thatare
are
AAdriver
driverisisnothing
nothingmore
more subordinate(calledby)
subordinate(called by)the
thecomponents
components
thanaa“Main
than “Mainprogram”
program”that,
that,
totobebetested.
tested.
accepts
acceptstest
testdata,
data,
ItItuses
usesthe
thesubordinate
subordinatemodule’s
module’sinterface,
interface,
passes
passesititto
tothe
thecomponent
component
tobe
betested,
tested, may
maydo dolittle
littledata
datamanipulation,
manipulation,
to
and
andprints
printsrelevant
relevantresults
results prints
printsverification
verificationof ofentry,
entry,
and
andreturns
returnscontrol
controltotothe
themodule
module
undergoingtesting
undergoing testing
Unit Testing Environment
driver
interface
local data structures
stu stu
b b
test cases
RESULTS
Comments
A
top module is
tested with stubs.
B F G
A
top module is tested with
stubs
B F G
D E
Top Down Integration
“Breadth first”
B F G
D E
Steps in Top-down Integration
B F G
cluster
Bottom Up Integration
A
B G
D1 D2
worker modules
are grouped into
clusters
Cluster 1
Cluster 2
Steps in Bottom-up Integration
1) Low-level modules are combined into clusters that
perform a specific software function
2) A driver (a control program for testing) is written to co-
ordinate test case input and output
3) The cluster is tested
4) Drivers are removed and clusters are combined moving
upwards in the program structure
Pros
Processing required for components to a given level is
always available
The need for stubs is eliminated
As integration moves upward, the need for separate test
drivers lessens
Cons
“the program as an entity does not exist until the last
module is added”
Sandwich Testing
A
top modules are
tested with stubs.
A combined approach
that uses top-down
tests for upper levels B F G
of the program
structure, coupled
with bottom-up tests
C
for sub-ordinate
levels worker modules are grouped
into builds and integrated.
D E
cluster
High-Order Testing
• Validation Testing
• Verifies conformance with requirements
• Answers the question “Did we build the correct
product?”
• Alpha and Beta Testing
• Testing by the customer of a near-final version
of the product.
• System Testing
• Testing of the entire software system, focused
on end-to-end qualities.
Validation Testing
• Validation succeeds when the software under test functions in
a manner that can reasonably be expected by the customer.
• Validation is achieved through a series of black-box tests that
demonstrate conformity with requirements.
• The test plan should outline the classes of tests to be
conducted and define specific test cases that will be used in an
attempt to uncover errors in conformity with requirements.
• Deviations or errors discovered at this stage in a project can
rarely be corrected prior to scheduled delivery
Alpha and Beta Testing
Alpha Test
software customer tests
developer site customer site
time required to
correct the error
and conduct
regression tests
time required to
diagnose the
symptom and
determine the cause
catastrophic
Damage extreme
serious
disturbing
annoying
mild
Bug Type
Acceptance tests
• Carried out by customers to validate all requirements
Alpha tests
• Conducted at developer’s site by a customer
• Conducted in controlled environment
Beta tests
• Conducted at customer’s site by end users
• Environment not controllable by developer
System Testing
Recovery testing - tests of fault tolerance (power
failures, hardware failures)
Security testing - tests to be sure hackers
cannot gain access or that users can only
access functions/data intended for them
Stress testing - tests limits of the system,
overload the amount or rate at which data comes
in.
Performance tests - verify the system works fast
enough, using the defined set of resources, etc.
Basis Path Testing
V(G) = E - N + 2
V(G) = P + 1
Where,
• R = Number of regions
• E = Number of edges
• N = Number of nodes
• P = Predicate nodes
Steps in Testing
1. Draw the flow graph
4. Prepare test cases that will force the execution of each path in the
basis set.
Example program
E = 11
N=9
V(G) = 11 – 9 + 2 = 4
P=3
V(G) = 3 + 1 = 4
R=4
V(G) = 4
V(G) is,…… 4
Let’s look at the paths
path 1: 1-11
Let’s look at the paths
path 1: 1-11
path 2: 1-2-3-4-5-10-1-11
Let’s look at the paths
path 1: 1-11
path 2: 1-2-3-4-5-10-1-11
path 3: 1-2-3-6-8-9-10-1-11
Let’s look at the paths
path 1: 1-11
path 2: 1-2-3-4-5-10-1-11
path 3: 1-2-3-6-8-9-10-1-11
path 4: 1-2-3-6-7-9-10-1-11
Great, so now what?
So now you set about to design test cases that cause the
basis set of paths to execute
To summarize:
1. Using the code, draw the flow graph
2. Determine V(G) of the flow graph
3. Determine a basis set of independent paths
4. Prepare a set of test cases that will force all paths in the
basis set
Example
Draw the flow graph, calculate the cyclomatic
complexity, list the basis paths and prepare a test case for
one path using the following C++ code fragment:
2 4 5
Cyclomatic Complexity:
V(G) = number of enclosed areas + 1 = 5
V(G) = number of simple predicates + 1 = 5
V(G) = edges - nodes + 2 = 10 - 7 + 2 = 5
1 3 6 7
2 4 5
1-7 (value[i] = -999.0)
1-2-7 (value[i] = 0, totinputs = 100)
1-2-3-6-1-7
1-2-3-4-6-1-7
1-2-3-4-5-6-1-7
1 3 6 7
2 4 5
Cyclomatic Complexity
A number of industry studies have indicated
that the higher V(G), the higher the probability
or errors.
modules
V(G)
1 2 3 4 5
1 1 1
a
2
e 3
b 3 1 1
d
5 4
f 4 1 1
c
g
2 5 1 1
requirements
output
input events
Black-Box
Finds Errors In:
Incorrect or missing functions
Interface errors
Data structures or external data base access
Performance errors
Initialization and termination errors
Black-Box Testing Methods
Graph-Based Testing
Equivalence Partitioning
Comparison Testing
Equivalence Partitioning Method
Divides the input domain of a program into
classes of data from which test cases can be
derived.
Test case design is based on an evaluation of
equivalence classes for an input condition.
Equivalence class represents a set of valid or
invalid states for input conditions.
Black-box Testing — Equivalence Partitioning
System
Outputs
Boundary Value Analysis Method
Create test cases that exercise bounding values(The edges
of the class)
Complements equivalence class testing
Derives test cases from the input and output domain as
well
Guidelines For Boundary Value
Range A to B, Test case for values A and B and just above
and below A and B.
Set of values, Test cases for the min and max values and
just above and below.
The above applies to output conditions.
Internals programs data structures boundary,test cases for
this boundaries.
Black-box Testing — Boundary Value Analysis
Faults frequently exist at and on either side of the
boundaries of equivalence sets
For a range v1 ... v2, test data should be designed with v1
and v2, just above and just below v1 and v2, respectively
Example
Suppose that the range is 1 ... 25
Then test data are 0, 1, 2, 24, 25, 26
Equivalence Partitioning:
Sample Equivalence Classes
Valid data
user supplied commands
responses to system prompts
file names
computational data
physical parameters
bounding values
initiation values
output data formatting
responses to error messages
graphical data (e.g., mouse picks)
Invalid data
data outside bounds of the program
physically impossible data
proper value supplied in wrong place
References:
Software Engineering - A practitioner’ s Approach
by Roger S. Pressman (6th Ed)
14.3, 14.4