Software Testing
Software Testing
5/11/2024
Objectives
• To explain the different types of testing techniques
used to discover program faults
5/11/2024
The testing process
• Component (Unit) Testing:
needs source code (White-box)
Testing of individual program components
Usually the responsibility of the component developer
Tests are derived from the developer’s experience
5/11/2024
Testing phases
Component Integration
(Unit) testing
testing
5/11/2024
Types of testing
• Defect testing
Exhaustive Testing
Black-box testing
Equivalence partitioning
White-box ‘Structural’ testing
Path testing
• Integration testing
• Interface testing
• Stress testing
• Object-oriented (OO) testing
• XP Automated testing
• Acceptance testing
• Testing workbenches
5/11/2024
Statistics:
Defect Distribution in SW Life Cycle
Defect Distributrion in Software Processes "SW Life Cycle"
Others
Requirements
10%
Design
Code
7% Code
Others
Requirements
56%
Design
27%
5/11/2024
Testing & Verification & Validation
5/11/2024
Use Cases & Functional Test Cases
• Write functional test case early
Happy path
Test
Result
Alternate flow
Exceptional flow
Functional
Tests
Output
5/11/2024
Who Tests the Software
•
5/11/2024
Test data and test cases
• Test data
Inputs to test the system
5/11/2024
What is Defect testing?
Testing is:
5/11/2024
The defect testing process
Deliverable
Specs of test input & predicted sys output
Process
5/11/2024
Black-box testing
• Program is considered as a ‘black-box’
• No need to know or access source code
• Functionality testing
• No implementation testing (implementation
testing needs source code)
• Test cases are based on the system specification
• Test planning can begin early in the software
process
5/11/2024
Black-box Testing
“Functionality testing”
Input:
Test Case
Program
Sys Input Sys Output Compare
“No need
for source
code” Output: Test
Report
5/11/2024
Black-box Testing
Inputs causing
anomalous
Input test data I behaviour
e
5/11/2024
Equivalence partitioning
• Objective:
5/11/2024
Equivalence partitioning - cont.
• A way to derive test cases
• Is a black-box testing method
• Input data with common characteristics (positive numbers,
negative numbers, strings without blanks, etc)
• Each of these classes is an equivalence partition
• Program behaves in an equivalent way for each member of
an Equivalence partition
• Divides the input domain into classes of data form which
test cases can be derived
5/11/2024
Equivalence partitioning – cont.
Input
Invalid inputs Valid inputs
System
Outputs
5/11/2024
Equivalence partitioning - cont.
• Guidelines for test case selection for partitions
At the boundaries of the partition
Close to mid-point of the partition
Equivalence Partition
Mid-point Value
5/11/2024
Equivalence partitioning - Example 1
• Program specs states:
Accepts 4 to 10 inputs
Each input is 5-digit integer greater > = than 10,000
5/11/2024
Equivalence partitioning - cont.
Example
3 Valid 11
4 7 10
Invalid Invalid
Less than 10000 Between 10000 and 99999 More than 99999
Invalid
Input values Invalid
5/11/2024
Equivalence partitioning - cont. Example 1
• If input is a 5-digit integer between 10,000 and 99,999, equivalence
partitions are
<10,000,
10,000 - 99, 999
and > 99, 999
5/11/2024
Structural testing ‘White-box
testing’
• Synonyms:
Glass-box, Clear-box, Transparent-box
• For small program units
• Needs source code
5/11/2024
White-box testing
Test data
Tests Derives
Component Test
code outputs
5/11/2024
Program flow graphs
• Flow Graph:
nodes representing program decisions
arcs representing the flow of control
Ignore sequential statements (assignments, procedures calls, I/O)
• Cyclomatic complexity =
Number of edges - Number of nodes + 2
5/11/2024
Cyclomatic complexity
• Cyclomatic complexity = number of tests to test
all control statements
5/11/2024
Example: Path testing
Binary search flow graph
1
8 4
(if (elemArray [mid]< key
5 6
9
5/11/2024
Independent paths
• Cyclomatic complexity = 11 - 9 + 2 = 4
5/11/2024
Integration testing (black-box)
• Tests complete systems or subsystems composed
of integrated components
5/11/2024
Incremental integration testing
Recall: XP Continuous Integration of: Stories + (Acceptance & Unit Tests)
A T1
Minimal system
T1
A
T1 T2
A B
T2
T2 B T3
T3
B C
T3 T4
C
T4
D T5
5/11/2024
Approaches to integration testing
• Top-down integration testing
Start with high-level system and integrate from the top-down
replacing individual components by stubs
Stubs have the same interface as the components but very limited
functionality
5/11/2024
Top-down integration testing
Testing
Level 1 Level 1 . ..
sequence
Level 2
stubs
Level 3
stubs
5/11/2024
Bottom-up integration testing
Test
drivers
Testing
Level N Level N Level N Level N Level N
sequence
Test
drivers
Level N–1 Level N–1 Level N–1
5/11/2024
Testing 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
5/11/2024
Interface testing
• Takes place when modules or sub-systems are
integrated to create larger systems
5/11/2024
Interface testing
Test
cases
A B
5/11/2024
Interfaces types
• Parameter interfaces
Data passed from one procedure to another
5/11/2024
Interface testing guidelines
• Design tests so that parameters to a called
procedure are at the extreme ends of their ranges
5/11/2024
Stress testing
• Exercises the system beyond its maximum design load.
• Stressing the system often causes defects to come to light
• Stress testing failure behaviour..
Systems should not fail catastrophically.
Stress testing checks for unacceptable loss of service or data
5/11/2024
Object-oriented (OO) testing
5/11/2024
Object-oriented testing:
Testing levels
• Testing operations (methods)
associated with objects
Testing levels :
• Testing object classes
• Testing clusters of cooperating
objects
• Testing the complete OO
system
5/11/2024
Object class testing
• Complete test coverage of a class involves:
Testing all operations (methods) associated with an
object
Setting and Getting all object attributes
(Recall: XP Unit testing for all methods and attributes
of a class)
5/11/2024
Key Testing Issues
• Give high testing priority for parts of a system which are
commonly used
give less priority for parts which are rarely executed
• Equivalence partitions
are sets of test cases where the program should behave in an
equivalent way
aims at reducing the number of test cases
• Black-box testing is based on the system specification
• Structural testing identifies test cases which cause all paths
through the program to be executed
5/11/2024
Key Testing Issues
• Test coverage:
measures ensure that all statements have been executed
at least once.
• For OO testing:
test object classes, test all operations, attributes and
states
5/11/2024