SE Module-5 (Software Testing )
SE Module-5 (Software Testing )
Software Testing
Strategies
& Testing Tactics
Module – V Syllabus
[ Chapter – 13 & 14 ]
Tasting Strategies and Testing Tactics:
Strategic Approach to software Testing,
Test Strategies for conventional and Object Oriented
Software,
Validation Testing,
System Testing,
White Box Testing,
Basic Path Testing,
Control Structure Testing,
Black Box Testing,
Object Oriented Testing Methods.
04/23/25 2
Introduction
• A strategy for software testing integrates the design of
software test cases into a well-planned series of steps
that result in successful development of the software
• The strategy provides a road map that describes the
steps to be taken, when, and how much effort, time, and
resources will be required
• The strategy incorporates test planning, test case
design, test execution, and test result collection and
evaluation
• The strategy provides guidance for the practitioner and a
set of milestones for the manager
• Because of time pressures, progress must be
measurable and problems must surface as early as
possible
04/23/25 3
General Characteristics of Strategic Testing
04/23/25 4
Verification and Validation
• Software testing is part of a broader group of activities
called verification and validation that are involved in
software quality assurance
04/23/25 6
A Strategy for Testing Conventional Software
System Testing
r s to
pe
Validation Testing
de w
co
o a ro
Br Nar
Integration Testing
Unit Testing
Code
Design
re to
nc t
co strac
te
Requirements
Ab
System Engineering
04/23/25 7
Levels of Testing for Conventional Software
• Unit testing
– Concentrates on each component/function of the software as
implemented in the source code
• Integration testing
– Focuses on the design and construction of the software
architecture
• Validation testing
– Requirements are validated against the constructed software
• System testing
– The software and other system elements are tested as a whole
04/23/25 8
Testing Strategy applied to Conventional Software
• Unit testing
– Exercises specific paths in a component's control structure to ensure
complete coverage and maximum error detection
– Components are then assembled and integrated
• Integration testing
– Focuses on inputs and outputs, and how well the components fit
together and work together
• Validation testing
– Provides final assurance that the software meets all functional,
behavioral, and performance requirements
• System testing
– Verifies that all system elements (software, hardware, people,
databases) mesh properly and that overall system function and
performance is achieved
04/23/25 9
Testing Strategy applied to Object-Oriented
Software
04/23/25 10
When is Testing Complete?
• There is no definitive answer to this question
• Every time a user executes the software, the program is
being tested
• Sadly, testing usually stops when a project is running out
of time, money, or both
• One approach is to divide the test results into various
severity levels
– Then consider testing to be complete when certain levels of
errors no longer occur or have been repaired or eliminated
04/23/25 11
Ensuring a Successful Software Test Strategy
04/23/25 12
Unit Testing
04/23/25 13
Targets for Unit Test Cases
• Module interface
– Ensure that information flows properly into and out of the module
• Local data structures
– Ensure that data stored temporarily maintains its integrity during all
steps in an algorithm execution
• Boundary conditions
– Ensure that the module operates properly at boundary values
established to limit or restrict processing
• Independent paths (basis paths)
– Paths are exercised to ensure that all statements in a module have
been executed at least once
• Error handling paths
– Ensure that the algorithms respond correctly to specific error conditions
04/23/25 14
Common Computational Errors in Execution Paths
04/23/25 15
Other Errors to Uncover
• Comparison of different data types
04/23/25 17
Drivers and Stubs for Unit Testing
• Driver
– A simple main program that accepts test case data, passes
such data to the component being tested, and prints the
returned results
• Stubs
– Serve to replace modules that are subordinate to (called by)
the component to be tested
– It uses the module’s exact interface, may do minimal data
manipulation, provides verification of entry, and returns
control to the module undergoing testing
04/23/25 18
Integration Testing
• Defined as a systematic technique for constructing the
software architecture
– At the same time integration is occurring, conduct
tests to uncover errors associated with interfaces
• Objective is to take unit tested modules and build a
program structure based on the prescribed design
• Two Approaches
– Non-incremental Integration Testing
– Incremental Integration Testing
04/23/25 19
Non-incremental Integration
Testing
• Commonly called the “Big Bang” approach
• Chaos results
• Once a set of errors are corrected, more errors occur, and testing
appears to enter an endless loop
04/23/25 20
Incremental Integration Testing
• Three kinds
– Top-down integration
– Bottom-up integration
– Sandwich integration
• The program is constructed and tested in small
increments
• Errors are easier to isolate and correct
• Interfaces are more likely to be tested completely
• A systematic test approach is applied
04/23/25 21
Top-down Integration
• Modules are integrated by moving downward through the
control hierarchy, beginning with the main module
• Subordinate modules are incorporated in either a depth-
first or breadth-first fashion
– DF: All modules on a major control path are integrated
– BF: All modules directly subordinate at each level are integrated
• Advantages
– This approach verifies major control or decision points early in
the test process
• Disadvantages
– Stubs need to be created to substitute for modules that have not
been built or tested yet; this code is later discarded
– Because stubs are used to replace lower level modules, no
significant data flow can occur until much later in the
integration/testing process
04/23/25 22
Bottom-up Integration
• Integration and testing starts with the most atomic
modules in the control hierarchy
• Advantages
– This approach verifies low-level data processing early in the
testing process
– Need for stubs is eliminated
• Disadvantages
– Driver modules need to be built to test the lower-level modules;
this code is later discarded or expanded into a full-featured
version
– Drivers inherently do not contain the complete algorithms that
will eventually use the services of the lower-level modules;
consequently, testing may be incomplete or more testing may be
needed later when the upper level modules are available
04/23/25 23
Sandwich Integration
• Consists of a combination of both top-down and bottom-up
integration
• Occurs both at the highest level modules and also at the
lowest level modules
• Proceeds using functional groups of modules, with each
group completed before the next
– High and low-level modules are grouped based on the control and
data processing they provide for a specific program feature
– Integration within the group progresses in alternating steps
between the high and low level modules of the group
– When integration for a certain functional group is complete,
integration and testing moves onto the next group
• Reaps the advantages of both types of integration while
minimizing the need for drivers and stubs
• Requires a disciplined approach so that integration doesn’t
tend towards the “big bang” scenario
04/23/25 24
Regression Testing
• Each new addition or change to baselined software may
cause problems with functions that previously worked
flawlessly
• Regression testing re-executes a small subset of tests that
have already been conducted
– Ensures that changes have not propagated unintended side effects
– Helps to ensure that changes do not introduce unintended behavior or
additional errors
– May be done manually or through the use of automated
capture/playback tools
• Regression test suite contains three different classes of test
cases
– A representative sample of tests that will exercise all software
functions
– Additional tests that focus on software functions that are likely to be
affected by the change
– Tests that focus on the actual software components that have been
changed
04/23/25 25
Smoke Testing
• Taken from the world of hardware
– Power is applied and a technician checks for sparks, smoke, or other dramatic
signs of fundamental failure
• Designed as a pacing mechanism for time-critical projects
– Allows the software team to assess its project on a frequent basis
• Includes the following activities
– The software is compiled and linked into a build
– A series of breadth tests is designed to expose errors that will keep the build
from properly performing its function
• The goal is to uncover “show stopper” errors that have the highest likelihood of
throwing the software project behind schedule
– The build is integrated with other builds and the entire product is smoke tested
daily
• Daily testing gives managers and practitioners a realistic assessment of the
progress of the integration testing
– After a smoke test is completed, detailed test scripts are executed
04/23/25 26
Benefits of Smoke Testing
04/23/25 27
Test Strategies for
Object-Oriented Software
Test Strategies for Object-Oriented
Software
• With object-oriented software, you can no longer test a
single operation in isolation (conventional thinking)
• Traditional top-down or bottom-up integration testing has
little meaning
• Class testing for object-oriented software is the
equivalent of unit testing for conventional software
– Focuses on operations encapsulated by the class and the state
behavior of the class
• Drivers can be used
– To test operations at the lowest level and for testing whole
groups of classes
– To replace the user interface so that tests of system functionality
can be conducted prior to implementation of the actual interface
• Stubs can be used
– In situations in which collaboration between classes is required
but one or more of the collaborating classes has not yet been
fully implemented
04/23/25 29
Test Strategies for Object-Oriented Software
(continued)
• Two different object-oriented testing strategies
– Thread-based testing
• Integrates the set of classes required to respond to one input or
event for the system
• Each thread is integrated and tested individually
• Regression testing is applied to ensure that no side effects occur
– Use-based testing
• First tests the independent classes that use very few, if any, server
classes
• Then the next layer of classes, called dependent classes, are
integrated
• This sequence of testing layer of dependent classes continues until
the entire system is constructed
04/23/25 30
Validation Testing
Background
• Validation testing follows integration testing
• The distinction between conventional and object-oriented software
disappears
• Focuses on user-visible actions and user-recognizable output from the
system
• Demonstrates conformity with requirements
• Designed to ensure that
– All functional requirements are satisfied
– All behavioral characteristics are achieved
– All performance requirements are attained
– Documentation is correct
– Usability and other requirements are met (e.g., transportability,
compatibility, error recovery, maintainability)
• After each validation test
– The function or performance characteristic conforms to specification and is
accepted
– A deviation from specification is uncovered and a deficiency list is created
• A configuration review or audit ensures that all elements of the software
configuration have been properly developed, cataloged, and have the
necessary detail for entering the support phase of the software life 32
04/23/25
cycle
Alpha and Beta Testing
• Alpha testing
– Conducted at the developer’s site by end users
– Software is used in a natural setting with developers watching intently
– Testing is conducted in a controlled environment
• Beta testing
– Conducted at end-user sites
– Developer is generally not present
– It serves as a live application of the software in an environment that
cannot be controlled by the developer
– The end-user records all problems that are encountered and reports
these to the developers at regular intervals
• After beta testing is complete, software engineers make software
modifications and prepare for release of the software product to the
entire customer base
04/23/25 33
System Testing
Different Types
• Recovery testing
– Tests for recovery from system faults
– Forces the software to fail in a variety of ways and verifies that recovery is
properly performed
– Tests reinitialization, checkpointing mechanisms, data recovery, and restart for
correctness
• Security testing
– Verifies that protection mechanisms built into a system will, in fact, protect it
from improper access
• Stress testing
– Executes a system in a manner that demands resources in abnormal quantity,
frequency, or volume
• Performance testing
– Tests the run-time performance of software within the context of an integrated
system
– Often coupled with stress testing and usually requires both hardware and
software instrumentation
– Can uncover situations that lead to degradation and possible system failure
04/23/25 35
The Art of Debugging
Debugging Process
04/23/25 37
Debugging Process
04/23/25 38
Why is Debugging so Difficult?
04/23/25 39
Why is Debugging so Difficult? (cont…)
04/23/25 40
Debugging Strategies
• Objective of debugging is to find and correct the cause of a software
error
• Bugs are found by a combination of systematic evaluation, intuition,
and luck
• Debugging methods and tools are not a substitute for careful
evaluation based on a complete design model and clear source
code
• There are three main debugging strategies
– Brute force
– Backtracking
– Cause elimination
04/23/25 41
Strategy #1: Brute Force
• Most commonly used and least efficient method
• Used when all else fails
• Involves the use of memory dumps, run-time traces, and
output statements
• Leads many times to wasted effort and time
04/23/25 42
Strategy #2: Backtracking
• Can be used successfully in small programs
• The method starts at the location where a symptom has
been uncovered
• The source code is then traced backward (manually)
until the location of the cause is found
• In large programs, the number of potential backward
paths may become unmanageably large
04/23/25 43
Strategy #3: Cause Elimination
• Involves the use of induction or deduction and introduces the
concept of binary partitioning
– Induction (specific to general): Prove that a specific starting value is
true; then prove the general case is true
– Deduction (general to specific): Show that a specific conclusion follows
from a set of general premises
• Data related to the error occurrence are organized to isolate
potential causes
• A cause hypothesis is devised, and the aforementioned data
are used to prove or disprove the hypothesis
• Alternatively, a list of all possible causes is developed, and
tests are conducted to eliminate each cause
• If initial tests indicate that a particular cause hypothesis shows
promise, data are refined in an attempt to isolate the bug
04/23/25 44
Three Questions to ask Before Correcting the Error
04/23/25 45
Chapter 14
Software Testing Techniques
Characteristics of Testable Software
• Operable
– The better it works (i.e., better quality), the easier it is to test
• Observable
– Incorrect output is easily identified; internal errors are
automatically detected
• Controllable
– The states and variables of the software can be controlled
directly by the tester
• Decomposable
– The software is built from independent modules that can be
tested independently
04/23/25 47
Characteristics of Testable Software (cont..)
• Simple
– The program should exhibit functional, structural, and code
simplicity
• Stable
– Changes to the software during testing are infrequent and
do not invalidate existing tests
• Understandable
– The architectural design is well understood; documentation
is available and organized
04/23/25 48
Test Characteristics
• A good test has a high probability of finding an error
– The tester must understand the software and how it might fail
• A good test is not redundant
– Testing time is limited; one test should not serve the same
purpose as another test
• A good test should be “best of breed”
– Tests that have the highest likelihood of uncovering a whole
class of errors should be used
• A good test should be neither too simple nor too
complex
– Each test should be executed separately; combining a series of
tests could cause side effects and mask certain errors
04/23/25 49
Two Unit Testing Techniques
• Black-box testing
– Knowing the specified function that a product has been
designed to perform, test to see if that function is fully
operational and error free
– Includes tests that are conducted at the software interface
– Not concerned with internal logical structure of the software
• White-box testing
– Knowing the internal workings of a product, test that all internal
operations are performed according to specifications and all
internal components have been exercised
– Involves tests that concentrate on close examination of
procedural detail
– Logical paths through the software are tested
– Test cases exercise specific sets of conditions and loops
04/23/25 50
White-box Testing
White-box Testing
• Uses the control structure part of component-level design to derive
the test cases
• These test cases
– Guarantee that all independent paths within a module have been
exercised at least once
– Exercise all logical decisions on their true and false sides
– Execute all loops at their boundaries and within their operational bounds
– Exercise internal data structures to ensure their validity
04/23/25 53
Flow Graph Notation
04/23/25 54
Flow Graph Example
FLOW CHART FLOW GRAPH
0 0
R4
1 1
2 2
3 R3
3
6 4 6 4
R2
7 8 5
7 R1 8 5
9
9
11 04/23/25 10 55
11 10
Independent Program Paths
• Defined as a path through the program from the start node until
the end node that introduces at least one new set of processing
statements or a new condition (i.e., new nodes)
• Must move along at least one edge that has not been traversed
before by a previous path
• Basis set for flow graph on previous slide
– Path 1: 0-1-11
– Path 2: 0-1-2-3-4-5-10-1-11
– Path 3: 0-1-2-3-6-8-9-10-1-11
– Path 4: 0-1-2-3-6-7-9-10-1-11
• The number of paths in the basis set is determined by the
cyclomatic complexity
04/23/25 56
Cyclomatic Complexity
04/23/25 57
Deriving the Basis Set and Test Cases
1) Using the design or code as a foundation, draw a corresponding
flow graph
2) Determine the cyclomatic complexity of the resultant flow graph
3) Determine a basis set of linearly independent paths
4) Prepare test cases that will force execution of each path in the
basis set
04/23/25 58
A Second Flow Graph Example
1 int functionY(void) 3
2 {
3 int x = 0; 4
4 int y = 19;
5 A: x++; 5
6 if (x > 999)
7 goto D;
8 if (x % 11 == 0) 6
9 goto B;
0 else goto A; 8 7
1 B: if (x % y == 0) 10 9 16
2 goto C;
3 else goto A;
11 17
4 C: printf("%d\n", x);
5 goto A; 13 12
6 D: printf("End of list\n");
7 return 0; 14
8 }
04/23/25 59
15
A Sample Function to Diagram and Analyze
1 int functionZ(int y)
2 {
3 int x = 0;
0 printf("End of list\n");
1 return
04/23/25 0; 60
2 } // End functionZ
A Sample Function to Diagram and Analyze
1 int functionZ(int y) 3
2 {
3 int x = 0;
4
4 while (x <= (y * y))
5 { 6 7
6 if ((x % 11 == 0) &&
7 (x % y == 0))
9
8
9
{
printf(“%d”, x);
12 13
0 x++;
1 } // End if 10
2 else if ((x % 7 == 0) || 15
3 (x % y == 1))
4 { 16
5 printf(“%d”, y);
6 x = x + 2; 18
7 } // End else
8 printf(“\n”);
9 } // End while 20
0 printf("End of list\n"); 21
1 return
04/23/25 0; 61
2 } // End functionZ
Loop Testing - General
• A white-box testing technique that focuses exclusively on the validity
of loop constructs
• Four different classes of loops exist
– Simple loops
– Nested loops
– Concatenated loops
– Unstructured loops
• Testing occurs by varying the loop boundary values
– Examples:
04/23/25 62
Testing of Simple Loops
1) Skip the loop entirely
2) Only one pass through the loop
3) Two passes through the loop
4) m passes through the loop, where m < n
5) n –1, n, n + 1 passes through the loop
04/23/25 63
Testing of Nested Loops
1) Start at the innermost loop; set all other loops to minimum values
2) Conduct simple loop tests for the innermost loop while holding the
outer loops at their minimum iteration parameter values; add other
tests for out-of-range or excluded values
3) Work outward, conducting tests for the next loop, but keeping all
other outer loops at minimum values and other nested loops to
“typical” values
4) Continue until all loops have been tested
04/23/25 64
Testing of Concatenated Loops
• For independent loops, use the same approach as for simple loops
• Otherwise, use the approach applied for nested loops
04/23/25 65
Testing of Unstructured Loops
• Redesign the code to reflect the use of structured programming
practices
• Depending on the resultant design, apply testing for simple loops,
nested loops, or concatenated loops
04/23/25 66
Black-box Testing
04/23/25 67
Black-box Testing
04/23/25 68
Black-box Testing Categories
• Incorrect or missing functions
• Interface errors
• Errors in data structures or external data base access
• Behavior or performance errors
• Initialization and termination errors
04/23/25 69
Questions answered by
Black-box Testing
04/23/25 70
Equivalence Partitioning
04/23/25 71
Guidelines for Defining Equivalence Classes
04/23/25 72
Boundary Value Analysis
• A greater number of errors occur at the boundaries of the input
domain rather than in the "center"
• Boundary value analysis is a test case design method that
complements equivalence partitioning
– It selects test cases at the edges of a class
– It derives test cases from both the input domain and output domain
04/23/25 73
Guidelines for Boundary Value Analysis
04/23/25 74
Object-Oriented Testing Methods
04/23/25 75
Introduction
04/23/25 76
Testing Implications for Object-Oriented Software
04/23/25 77
Applicability of Conventional Testing Methods
04/23/25 78
Fault-based Testing
• The objective in fault-based testing is to design tests that have a
high likelihood of uncovering plausible faults
• Fault-based testing begins with the analysis model
– The tester looks for plausible faults (i.e., aspects of the implementation
of the system that may result in defects)
– To determine whether these faults exist, test cases are designed to
exercise the design or code
• If the analysis and design models can provide insight into what is
likely to go wrong, then fault-based testing can find a significant
number of errors
04/23/25 79
Fault-based Testing (continued)
04/23/25 80
Fault-based Testing vs. Scenario-based Testing
04/23/25 81
Random Order Testing (at the Class Level)
04/23/25 82
Partition Testing (at the Class Level)
04/23/25 83
Multiple Class Testing
04/23/25 84
Tests Derived from Behavior Models
04/23/25 85