Module 3-Software Testing
Module 3-Software Testing
Module-3
13/07/2025 1
Software Testing
Computer programs are designed and developed by human beings
and hence are prone to errors.
If unchecked, they can lead to a lot of problems, including social
implications.
Testing the software becomes an essential part of the software
development lifecycle.
Carrying out the testing activities for projects has to be practiced
with proper planning and must be implemented correctly.
Software testing is a critical element of software quality assurance
and represents the ultimate review of specification, design, and
code generation
13/07/2025 2
Software Testing
• Because of human error, There will be a software bug or
fault in the code and if that executed it becomes failure.
13/07/2025 3
What is Software Testing
Definitions of Testing:
Test is a formal activity. It involves a strategy and a systematic approach.
The different stages of tests supplement each other. Tests are always
specified and recorded.
Test is a planned activity. The workflow and the expected results are
specified. Therefore the duration of the activities can be estimated.
13/07/2025 5
Objectives of testing
Testing is a process of executing a program with the intent of
finding an error.
A good test case is one that has a high probability of finding an
as-yet- undiscovered error.
A successful test is one that uncovers an as-yet-undiscovered
error.
13/07/2025 6
Principles of Testing
1.Testing shows the presence of defects
• Software testing talks about the presence of defects and doesn’t talk about the absence of defects.
• Testing can reduce the number of defects but not remove all defects.
3.Early testing
• The defect detected in the early phases of SDLC will be very less expensive.
4.Defect clustering
• In a project, a small number of modules can contain most of the defects.
5.Pesticide paradox
• Repeating the same test cases, again and again, will not find new bugs.
6.Testing is context-dependent
• Different types of software need to perform different types of testing.
13/07/2025 8
Testing fundamentals (cont’d)
Activities of tester:
Prepare test plan and test data
Design test cases and test scripts
Perform testing
Track defects in the defect management
system
Participate in the test review meeting
Prepare test report
Follows software standards.
13/07/2025 9
Software Test Activities
• Testing is a long activity in which several test cases are executed.
• Testing is carry out by different teams in different environments and machines.
• So, testing phase contains different activities:
13/07/2025 10
Test activities(cont’d) Test case to issue a book to the student member from
library
Test plan ID TP-001
Design test cases
A test case is a set of Test case ID TC-001
input and expected Features to be tested Issuance of book to member
output under which a
Preconditions 1. Library membership is mandatory
program unit is 2. Book quota limit should be <5
exercised with the
Test script 1. Verify membership
purpose of causing 2. Check book availability
failure and detecting 3. Check number of book to be issued
faults. 4. Issue book
5. Add issued book details into member’s account.
6. Update library catalog
Test Data 1. Valid membership ID
2. 2. Invalid membership ID
3. Valid book limit: 1,4
4. Invalid book limit: 5, 6, 9
Expected results 1. Book should be issued if the member has valid membership card.
2. Display “renew membership” if membership expired.
3. Book limit should be within 5
Test status Pass
13/07/2025 11
Design test stubs and test drivers
13/07/2025 13
Approaches of test case design
• Black-box approach
• White-box (or glass-box) approach
Black-box approach
Black box testing is performed on the basis of software functions or features.
Only input values are considered for the design of test cases.
Output values that the software provides for test cases are observed.
Internal processing of software is not considered.
Different methods:
Equivalence class partitioning
Boundary value analysis
Cause-effect graphing
13/07/2025 14
Equivalence class partitioning
In the equivalence class partitioning approach, the domain of input values to the program under
test is partitioned into a set of equivalence classes.
The partitioning is done such that for every input data belonging to the same equivalence class,
the program behaves similarly.
Example: For a software that computes the square root of an input integer that can assume values
in the range of 0 and 5000. Determine the equivalence classes and the black box test suite.
Answer:
1. Three equivalence classes—set of negative integers, set of integers in the range of 0 and 5000,
and set of integers larger than 5000.
2. Therefore, the test cases must include representatives for each of
3. the three equivalence classes.
4. A possible test suite can be: {–5,500,6000}
13/07/2025 15
Example: Design equivalence class partitioning test suite for a
function that reads a character string of size less than five
characters and displays whether it is a palindrome?
Hints:
Identify the valid and invalid equivalence classes.
Take one representative of each equivalence class and design the
test suite.
13/07/2025 16
• Identifying Equivalence Classes
1.Valid Inputs
1. Palindromes of length 1-4
1. (Single character: "a")
2. (Two characters: "aa")
3. (Three characters: "aba")
4. (Four characters: "abba")
2. Non-palindromes of length 2-4
1. ("ab", "abc", "abcd")
2.Invalid Inputs
1. Empty String ("") – Edge case
2. Strings with 5 or more characters – Should be rejected
1. ("abcde", "abcdef")
3. Non-alphabetic characters
1. Numeric: "123", "121"
2. Special Characters: "@@", "a@a", "!@!"
13/07/2025 17
Test Case ID Input Expected Output Equivalence Class
13/07/2025 18
• Scenario: Testing the input field for "Age" in a registration form, where
the valid age range is 18 to 60.
• Step 1: Identify Input Conditions
• The system only accepts ages between 18 and 60 (inclusive). Any input
outside this range should be rejected.
13/07/2025 19
• Step 3: Select Test Cases
• From each equivalence class, we pick at least one test case:
Test Case ID Input Age Expected Output
TC001 18 Accepted
TC002 35 Accepted
TC003 60 Accepted
TC004 17 Rejected
TC005 61 Rejected
13/07/2025 20
Boundary value analysis
Boundary value analysis-based test suite design involves designing test cases
using the values at the boundaries of different equivalence classes.
Programmers often fail to properly address the special processing required by
the input values that lie at the boundary of the different equivalence classes. For
example, programmers may improperly use < instead of <=, or conversely <=
for <, etc.
Refined version of equivalence class partitioning .
Example: For a function that computes the square root of the integer values in
the range of 0 and 5000, determine the boundary value test suite.
Answer: There are three equivalence classes—
The set of negative integers,
set of integers in the range of 0 and 5000,
set of integers larger than 5000.
The boundary value-based test suite is: {0,-1,5000,5001}
13/07/2025 21
Example:
Let us assume there is a test case that takes the car speed from 40 km/hr- 80 km/hr,
and if the speed is lower than 40 and higher than 80, then our software should send
the notification. To test our software’s working, we will pick boundary values like
40,41,79,80. We will check our software performance on these boundary values. If
the values are entered below 40 and above 80 then it will be considered invalid case.
If the value entered is between 40-80 then it will be a valid case.
Answer:
Boundary Value Test Case
Invalid Test Case Valid Test Case Invalid Test Case
(Min Value-1) (Min,+Min,Max,-Max) (Max Value+1)
39 40,41,79,80 81
13/07/2025 22
Cause-effect Graphing
• The main drawback of equivalence class partitioning and boundary value analysis is consideration of only
one input domain.
• But such methods may fail when module takes input from various input conditions. Cause-effect method
is suitable for such situation.
Cause-effect graphing Technique:
• It is a graphical representation of a relationship between cause (input) and effect (outcome).
Example:
“Cash withdrawal” from ATM.
Solutions:
1. First identify potential causes and effects of the problem.
2. Draw the graph representing the relationship between causes and effects.
Causes:
C1: Enter valid amount
C2: Enter valid PIN
C3: Amount availability in ATM
Effect:
E1: Cash withdrawal.
13/07/2025 23
• E1 will be successful if C1, C2 and C3 is true.
C1
C2
∧ E1
C3
• Other cases may be possible also like invalid amount, invalid PIN, non availability of
cash in ATM. Such condition may also be represented in graph.
• Other notation of cause-effect graph: C1
C1
E1
Identity NOT E1 ∧
C1 E1 C1 E1 ∨
C2
C2
13/07/2025 24
Example: Perform the cause-effect graph to issue a book to the student of the
library and design the test cases.
1. Identify causes and effects. 2. Draw cause-effect graph
Causes:
C1: Library membership card C1
valid E1
C2: Expired membership card
C3: Verify book limit C2 ∧ E2
C4: availability of books in library
Effects: ∼
C3
E1: Renewal of membership card. ∧ E3
E2: Exceed book issue limit
E3: issue book
C4
13/07/2025 25
3. Design Decision table for test cases of each effects.
Causes Test 1 Test 2 Test 3
C1 X 1 1
C2 1 X X
C3 X 0 1
C4 X X 1
Effect
E1 1
E2 1
E3 1
13/07/2025 26
Error guessing
Error guessing" is a technique where testers leverage their experience
and intuition to predict potential areas where errors might occur in a
system.
Example scenarios for error guessing:
• Entering invalid data types into a field (e.g., letters in a number field)
• Testing with extremely large or small values to check boundary
conditions
• Simulating user errors like accidentally deleting important data
• Checking for system behavior when unexpected inputs are provided
13/07/2025 27
White box testing
In white box testing each testing strategy essentially designs test
cases based on analysis of some aspect of source code and is
based on some heuristic.
Types:
Coverage-based
Statement coverage,
Branch coverage,
Multiple condition coverage,
Path coverage-based testing
Fault-based
Mutation testing.
13/07/2025 28
Coverage-based Testing
A coverage-based testing strategy attempts to execute (or cover) certain elements of a program.
13/07/2025 30
Branch coverage based testing
13/07/2025 31
13/07/2025 32
13/07/2025 33
Example: Design branch coverage-based test suite for the following Euclid’s
GCD computation program:
int computeGCD(x, y)
int x, y;
{
while (x != y){
if (x>y) then
x=x-y;
else y=y-x;
}
return x;
}
Answer: The test suite {(x = 3, y = 3), (x = 3, y = 2), (x = 4, y = 3), (x = 3, y =
4)} achieves branch coverage
13/07/2025 34
Example: Find the test suite suing branch coverage technique for the following
problem.
int a;
if(a<0)
{
a = a+5;
}
printf(“a =%d”, a);
Answer:
if we take a = -2, it will executes all statements at least once. So it is
statement coverage test case.
But, a = -2 will not evaluate the if statement for false condition. Hence. It is
not branch coverage test case.
Therefore, (a=-2), (a=4), both are branch coverage test case.
13/07/2025 35
Multiple condition coverage testing
• It is used to cover all the conditions.
• Condition coverage is also known as predictive
coverage in which each one of the Boolean
expression have been evaluated to both true and
false condition.
13/07/2025 36
Path coverage based testing
• The basis path method enables the test-case designer to derive a logical
complexity measure of a procedural design and use this measure as a guide
for defining a basis set of execution paths.
• Test cases derived to exercise the basis set are guaranteed to execute every
statement in the program at least one time during testing.
13/07/2025 37
Control flow graph (CFG)
• It describes the flow of control within the
program.
• It is a finite set of nodes and edges. The
nodes represents the executable statements
and edges represents the flow of controls.
13/07/2025 38
McCabe’s Cyclomatic Complexity Metric
• McCabe’s cyclomatic complexity defines an upper bound on the
number of independent paths in a program.
• The number of independent paths helps to design different test
cases for the program.
Three ways to obtain cyclometric complexity:
C(C) = E-N+2 (E= edges, N= nodes)
13/07/2025 39
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = scanner.nextInt();
if (num % 2 == 0) {
System.out.println(num + " is even.");
else {
System.out.println(num + " is odd.");
}
scanner.close();
}
13/07/2025 40
Number of predicates (decision)
= 1.
Hence, C(C) = P+1 = 1+1 = 2
13/07/2025 41
Identifying the independent paths
• From the previous cyclometric complexity i.e., 2 number of independent path = 2.
• Hence, prepare any random test cases for all independent paths.
1
Example:
1. Greatest of numbers 2
2. Input (A)
3
3. Input (B)
4. If(A>B)
4
5. Then print (A)
6. Elseif(B>A)
5 6
7. Then print (B)
7 8
8. Else
Print(both are equal)
10 9
9. End if
10. End if 11
11. Exit
13/07/2025 42
Mutation Testing – Software
Testing
• Mutation Testing is a type of Software Testing that is performed to
design new software tests and also evaluate the quality of already
existing software tests. Mutation testing is related to modification a
program in small ways. It focuses to help the tester develop effective
tests or locate weaknesses in the test data used for the program.
13/07/2025 45
Unit testing
Here, individual units of software i.e. group of computer program modules, usage
procedures, and operating procedures are tested to determine whether they are suitable
for use or not.
An individual component may be either an individual function or a procedure.
Unit Testing is typically performed by the developer. In SDLC or V Model, Unit testing is
the first level of testing done before integration testing.
Unit testing is such a type of testing technique that is usually performed by developers.
Objectives:
To isolate a section of code.
To verify the correctness of the code.
To test every function and procedure.
To fix bugs early in the development cycle and to save costs.
To help the developers to understand the code base and enable them to make changes
quickly.
To help with code reuse.
13/07/2025 46
Unit testing with the help of driver and
A complete environment is needed to provide all
stub modules
relevant code that is necessary for execution of the
module.
Example:
it is checked that no parameter mismatch occurs when one module invokes the
functionality of another module. It ensure that there are no errors in parameter
passing, when one module invokes the functionality of another module.
13/07/2025 48
Types of Integration testing
• Big-bang approach
• Incremental approach
Top-down approach
Bottom up approach
Mixed/sandwich approach
13/07/2025 49
Big-bang approach:
13/07/2025 50
Incremental testing approach
Testing is done by integrating two or more
modules that are logically related and then
tested for proper functioning.
Top-down approach:
This approach begins with the main module and
moves downwards integrating and testing its lower-
level modules.
Advantage:
Major control and decisions are considered early
before testing the lower level modules.
Disadvantage:
Testing may be delayed for a module if lower-level
modules are not available.
Bottom-up approach:
Reverse process of top-down approach.
Lower-level modules are integrated function-wise to
form a subsystem and sub-system are integrated to
form main module.
13/07/2025 51
Sandwich approach: TOP DOWN APPROACH BOTTOM UP APPROACH
Bottom Up Integration testing is one of
Combination of both top-down and Top Down Integration testing is one of the
the approach of Integration testing in
approach of Integration testing in which
bottom-up approach. which integration testing takes place
01. integration testing takes place from top to
from bottom to top means system
bottom means system integration begins
Top-down approach forces the with top level modules.
integration begins with lowest level
modules.
lower-level modules to be available
In this testing the higher level modules In this testing the lower level modules
and bottom-up approach requires are tested first then the lower level are tested first then the higher level
upper-level modules. 02.
modules are tested and then the modules modules are tested and then the
are integrated accordingly. modules are integrated accordingly.
Most preferred approach as In this testing stubs are used for simulate In this testing drivers are used for
modules are tested as and when the submodule if the invoked submodule simulate the main module if the main
03.
they are available. is not developed means Stub works as a module is not developed means Driver
momentary replacement. works as a momentary replacement.
Bottom Up Integration testing
Top Down Integration testing approach is
approach is beneficial if the crucial
04. beneficial if the significant defect occurs
flaws encounters towards the bottom
toward the top of the program.
of the program.
In Top Down Integration testing approach In Bottom Up Integration testing
the main module is designed at first then approach different modules are
05.
the submodules/subroutines are called created first then these modules are
from it. integrated with the main function.
It is implemented on Structure/procedure- It is implemented on Object-oriented
06.
oriented programming languages. programming languages.
The complexity of this testing is
07. The complexity of this testing is simple.
complex and highly data intensive.
08. It works on big to small components. It works on small to big components.
In this approach Stub modules must be In this approach, Driver modules must
09.
produced. be produced.
13/07/2025 52
System testing
System Testing is a type of software testing that is performed on a complete integrated
system to evaluate the compliance of the system with the corresponding requirements.
In system testing, integration testing passed components are taken as input. The goal
of integration testing is to detect any irregularity between the units that are integrated
together.
System testing detects defects within both the integrated units and the whole system.
System testing test the system for functional requirements
Types :
Performance testing: Test the speed, scalability, stability and reliability of the software product
Volume testing: test amount of data the system can processed..
Stress testing: test system under stress situation.
Security testing: check security of system.
Recovery testing: test to recover any lost data.
Compatibility testing: new system (files) is compatible with older one.
Configuration testing: system can run on different h/w and s/w.
Installation testing: system is correctly installed or not.
Documentation testing: in operational stage, if any error come, manual is needed to overcome this
situation.
13/07/2025 53
Acceptance testing
This testing is performed before the system is released in the market.
It is performed with the customer to ensure that the system is acceptable for
delivery or not.
System is tested in customer point of view.
Types:
User testing: test the functionalities that frequently used by users.
Regulation testing: test the system based on certain regulation of the area
where the system to be deployed.
Alpha testing: Pilot testing (testing performed in a development
environment)
Beta testing: performed by limited and friendly customer.
13/07/2025 54