Software Testing Strategies Explained
Software Testing Strategies Explained
Strategies
1
Software Testing
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
errors
requirements conformance
performance
an indication
of quality
4
Strategic Approach
◼ To perform effective testing, conduct effective technical reviews. By
doing this, many errors will be eliminated before testing
commences.
5
V&V
◼ Software testing is part of a broader group of
activities called verification and validation that are
involved in software quality assurance
◼ Verification refers to the set of tasks that ensure that
software correctly implements a specific function.
◼ Validation refers to a different set of tasks that ensure
that the software that has been built is traceable to
customer requirements. Boehm [Boe81] states this
another way:
◼ Verification: "Are we building the product, right?"
◼ Validation: "Are we building the right product?"
6
Who Tests the Software?
7
Organizing for Software Testing
◼ Testing should aim at "breaking" the software
◼ Common misconceptions
◼ The developer of software should do no testing at all
◼ The software should be given to a secret team of testers who will
test it unmercifully
◼ The testers get involved with the project only when the testing steps
are about to begin
◼ Reality: Independent test group
◼ Removes the inherent problems associated with letting the builder
test the software that has been built
◼ Removes the conflict of interest that may otherwise be present
◼ Works closely with the software developer during analysis and
design to ensure that thorough testing occurs
8
Testing Strategy
System Testing
Validation Testing
Integration Testing
Unit Testing
Code
Design
Requirements
System Engineering
9
Criteria for Completion of Testing
10
Testing Strategy
11
Strategic Issues
12
Test Strategies for
Conventional Software
Unit Testing
◼ Focuses testing on the function or software module
◼ Concentrates on the internal processing logic and
data structures
◼ Is simplified when a module is designed with high
cohesion
◼ Reduces the number of test cases
◼ Allows errors to be more easily predicted and uncovered
◼ Concentrates on critical modules and those with high
cyclomatic complexity when testing resources are
limited
14
Unit Testing
module
to be
tested
results
software
engineer
test cases
15
Unit Testing
module
to be
tested
interface
local data structures
boundary conditions
independent paths
error handling paths
test cases
16
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
Common Computational Errors in
Execution Paths
19
Problems to uncover in Error Handling
◼ Error description is unintelligible or ambiguous
◼ Error noted does not correspond to error encountered
◼ Error condition causes operating system intervention
prior to error handling
◼ Exception condition processing is incorrect
◼ Error description does not provide enough information to
assist in the location of the cause of the error
20
Drivers and Stubs for Unit Testing
◼ Driver(section)
◼ A simple main program that accepts test case data, passes such
data to the component being tested, and prints the returned results
◼ Stubs(sum_
◼ 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
◼ Drivers and stubs both represent overhead
◼ Both must be written but don’t constitute part of the installed
software product
21
Unit Test Environment
driver
Section(n)
interface
local data structures
Stub stub
Sum(n1,n1..)
test cases
RESULTS
22
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
Non-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
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
Top Down Integration
A
top module is tested with
stubs
B F G
27
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
Bottom-Up Integration
A
B F G
cluster
29
Sandwich Integration
B F G
cluster
31
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
Smoke Testing
◼ A common approach for creating “daily builds” for product
software
◼ Smoke testing steps:
◼ Software components that have been translated into code are
integrated into a “build.”
• A build includes all data files, libraries, reusable modules, and
engineered components that are required to implement one or
more product functions.
◼ A series of tests is designed to expose errors that will keep
the build from properly performing its function.
• The intent should be 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
(in its current form) is smoke tested daily.
• The integration approach may be top down or bottom up.
33
Benefits of Smoke Testing
◼ Integration risk is minimized
◼ Daily testing uncovers incompatibilities and show-stoppers early in
the testing process, thereby reducing schedule impact
◼ The quality of the end-product is improved
◼ Smoke testing is likely to uncover both functional errors and
architectural and component-level design errors
◼ Error diagnosis and correction are simplified
◼ Smoke testing will probably uncover errors in the newest
components that were integrated
◼ Progress is easier to assess
◼ As integration testing progresses, more software has been
integrated and more has been demonstrated to work
◼ Managers get a good indication that progress is being made
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
Test Strategies for Object-Oriented
Software (continued)
40
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
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
44
Debugging: A Diagnostic Process
45
The Debugging Process
46
Debugging Effort
time required
to diagnose the
symptom and
time required determine the
to correct the error cause
and conduct
regression tests
47
Symptoms & Causes
symptom and cause may be
geographically separated
catastrophic
extreme
serious
disturbing
annoying
mild
Bug Type
50
Automated Debugging
◼ Different tools
◼ Integrated Development Environments (IDEs)
◼ Debugging compilers
◼ Dynamic Debugging aids
◼ Automated test case generators
◼ Cross reference mapping tools
51
Correcting the Error
◼ Is the cause of the bug reproduced in another part of the program? In
many situations, a program defect is caused by an erroneous
pattern of logic that may be reproduced elsewhere.
◼ What "next bug" might be introduced by the fix I'm about to make?
Before the correction is made, the source code (or, better, the
design) should be evaluated to assess coupling of logic and data
structures.
◼ What could we have done to prevent this bug in the first place? This
question is the first step toward establishing a statistical software
quality assurance approach. If you correct the process as well as
the product, the bug will be removed from the current program
and may be eliminated from all future programs.
52
Final Thoughts
◼ Think -- before you act to correct
◼ Use tools to gain additional insight
◼ If you’re at an impasse, get help from someone
else
◼ Once you correct the bug, use regression
testing to uncover any side effects
53