SE Unit4 Notes
SE Unit4 Notes
Software Testing
Testing is the process of evaluating a system or its component(s) with the intent
to find whether it satisfies the specified requirements or not. In simple words,
testing is executing a system in order to identify any gaps, errors, or missing
requirements in contrary to the actual requirements.
Testing Objective:
The main objectives and purposes of software testing are to
• Find defects in the software product that may have occurred during the
development of the software due to human error.
• Gain confidence and conclude the quality of the software developed.
• Prevent future defects from occurring.
• Identify the errors, faults, or missing requirements in contrast to actual
requirements.
• Measure the specification, functionality, and performance of a software
program or application.
Manual testing includes testing a software manually, i.e., without using any
automated tool or any script. In this type, the tester takes over the role of an end-
user and tests the software to identify any unexpected behavior or bug. There are
different stages for manual testing such as unit testing, integration testing, system
testing, and user acceptance testing.
Testers use test plans, test cases, or test scenarios to test a software to ensure the
completeness of testing. Manual testing also includes exploratory testing, as
testers explore the software to identify errors in it.
Automation Testing
Automation testing, which is also known as Test Automation, is when the tester
writes scripts and uses another software to test the product. This process involves
automation of a manual process. Automation Testing is used to re-run the test
scenarios that were performed manually, quickly, and repeatedly.
The technique of testing without having any knowledge of the interior workings
of the application is called black-box testing. The tester is oblivious to the system
architecture and does not have access to the source code. Typically, while
performing a black-box test, a tester will interact with the system's user interface
by providing inputs and examining outputs without knowing how and where the
inputs are worked upon.
The following table lists the advantages and disadvantages of black-box testing.
Advantages Disadvantages
Limited coverage, since only a
Well suited and efficient for large code selected number of test
segments. scenarios is actually
performed.
The tester needs to have a look inside the source code and find out which
unit/chunk of the code is behaving inappropriately.
The following table lists the advantages and disadvantages of white-box testing.
Advantages Disadvantages
Mastering the domain of a system always gives the tester an edge over someone
with limited domain knowledge. Unlike black-box testing, where the tester only
tests the application's user interface; in grey-box testing, the tester has access to
design documents and the database. Having this knowledge, a tester can prepare
better test data and test scenarios while making a test plan.
Advantages Disadvantages
The following table lists the points that differentiate black-box testing, grey-box
testing, and white-box testing.
Black-Box Testing Grey-Box Testing White-Box Testing
Also known as
Also known as closed- translucent testing, as Also known as clear-
box testing, data-driven the tester has limited box testing, structural
testing, or functional knowledge of the testing, or code-based
testing. insides of the testing.
application.
Testing is based on
Testing is done on the Internal workings are
external expectations -
basis of high-level fully known and the
Internal behaviour of
database diagrams and tester can design test
the application is
data flow diagrams. data accordingly.
unknown.
Not suited for Not suited for algorithm Suited for algorithm
algorithm testing. testing. testing.
This can only be done Data domains and Data domains and
by trial-and-error internal boundaries can internal boundaries
method. be tested, if known. can be better tested.
Software Testing - Levels
• Functional Testing
• Non-functional Testing
Functional Testing
There are five steps that are involved while testing an application for
functionality.
Steps Description
The output based on the test data and the specifications of the
III
application.
An effective testing practice will see the above steps applied to the testing policies
of every organization and hence it will make sure that the organization maintains
the strictest of standards when it comes to software quality.
Unit Testing
This type of testing is performed by developers before the setup is handed over
to the testing team to formally execute the test cases. Unit testing is performed by
the respective developers on the individual units of source code assigned areas.
The developers use test data that is different from the test data of the quality
assurance team.
The goal of unit testing is to isolate each part of the program and show that
individual parts are correct in terms of requirements and functionality.
There is a limit to the number of scenarios and test data that a developer can use
to verify a source code. After having exhausted all the options, there is no choice
but to stop unit testing and merge the code segment with other units.
Integration Testing
Bottom-up integration
1 This testing begins with unit testing, followed by tests of progressively
higher-level combinations of units called modules or builds.
Top-down integration
2 In this testing, the highest-level modules are tested first and
progressively, lower-level modules are tested thereafter.
The Stubs and Drivers are considered as elements which are equivalent
to to-do modules that could be replaced if modules are in their
developing stage, missing or not developed yet, so that necessity of such
modules could be met. Drivers and stubs simulate features and
functionalities, and have ability to serve features that a module can
provide. This reduces useless delay in testing and makes the testing
process faster.
Stubs are mainly used in Top-Down integration testing while the Drivers
are used in Bottom-up integration testing, thus increasing the efficiency of
testing process.
1.Stubs:
Stubs are developed by software developers to use them in place of
modules, if the respective modules aren’t developed, missing in
developing stage, or are unavailable currently while Top-down testing of
modules. A Stub simulates module which has all the capabilities of the
unavailable module. Stubs are used when the lower-level modules are
needed but are unavailable currently.
Stubs are divided into four basic categories based on what they do :
• Shows the traced messages,
• Shows the displayed message if any,
• Returns the corresponding values that are utilized by modules,
• Returns the value of the chosen parameters(arguments) that
were used by the testing modules.
2.Drivers:
Drivers serve the same purpose as stubs, but drivers are used in Bottom-
up integration testing and are also more complex than stubs. Drivers are
also used when some modules are missing and unavailable at time of
testing of a specific module because of some unavoidable reasons, to act
in absence of required module. Drivers are used when high-level modules
are missing and can also be used when lower-level modules are missing.
Ex : Suppose, you are told to test a website whose corresponding primary
modules are, where each of them is interdependent on each other, as
follows:
• Module-A : Login page website,
• Module-B : Home page of the website
• Module-C : Profile setting
• Module-D : Sign-out page
It’s always considered good practice to begin development of all modules
parallelly because as soon as each gets developed they can be integrated
and could be tested further as per their corresponding interdependencies
order with a module. But in some cases, if any one of them is in developing
stage or not available in the testing process of a specific module, stubs or
drivers could be used instead.
Assume Module-A is developed. As soon as it’s developed, it undergoes
testing, but it requires Module-B, which isn’t developed yet. So in this
case, we can use the Stubs or Drivers that simulate all features and
functionality that might be shown by actual Module-B. So, we can
conclude that Stubs and drivers are used to fulfill the necessity of
unavailable modules. Similarly, we may also use Stubs or Drivers in place
of Module-C and Module-D if they are too not available.
Do both drivers and Stubs serve the same functionality?
Yes, we can say both serve the same feature and are used in the absence
of a module (M1) that has interdependencies with an
other module(M2) that is need to be test, so we use drivers or stubs in
order to fulfill module(M1)’s unavailability’s and to serve its functionality.
Difference between Stubs and Drivers :
Stubs are basically known as a “called While, drivers are the “calling
2. programs” and are used in the Top- program” and are used in bottom-up
down integration testing. integration testing.
Stubs are similar to the modules of the While drivers are used to invoking
3. software, that are under development the component that needs to be
process. tested.
Stubs are taken into use to test the Whereas the drivers are used if the
5. feature and functionality of the main module of the software isn’t
modules. developed for testing.
Stubs are used when lower-level of Drivers are used when higher-level
modules are missing or in a partially of modules are missing or in a
7.
developed phase, and we want to test partially developed phase, and we
the main module. want to test the lower(sub)- module.
System Testing
System testing tests the system as a whole. Once all the components are
integrated, the application as a whole is tested rigorously to see that it meets the
specified Quality Standards. This type of testing is performed by a specialized
testing team.
• System testing is the first step in the Software Development Life Cycle,
where the application is tested as a whole.
• The application is tested thoroughly to verify that it meets the functional
and technical specifications.
• The application is tested in an environment that is very close to the
production environment where the application will be deployed.
• System testing enables us to test, verify, and validate both the business
requirements as well as the application architecture.
Regression Testing
• Minimize the gaps in testing when an application with changes made has
to be tested.
• Testing the new changes to verify that the changes made did not affect any
other area of the application.
• Mitigates risks when regression testing is performed on the application.
• Test coverage is increased without compromising timelines.
• Increase speed to market the product.
Acceptance Testing
Alpha Testing
This test is the first stage of testing and will be performed amongst the teams
(developer and QA teams). Unit testing, integration testing and system testing
when combined together is known as alpha testing. During this phase, the
following aspects will be tested in the application −
• Spelling Mistakes
• Broken Links
• Cloudy Directions
• The Application will be tested on machines with the lowest specification
to test loading times and any latency problems.
Beta Testing
This test is performed after alpha testing has been successfully performed. In beta
testing, a sample of the intended audience tests the application. Beta testing is
also known as pre-release testing. Beta test versions of software are ideally
distributed to a wide audience on the Web, partly to give the program a "real-
world" test and partly to provide a preview of the next release. In this phase, the
audience will be testing the following −
• Users will install, run the application and send their feedback to the project
team.
• Typographical errors, confusing application flow, and even crashes.
• Getting the feedback, the project team can fix the problems before
releasing the software to the actual users.
• The more issues you fix that solve real user problems, the higher the quality
of your application will be.
• Having a higher-quality application when you release it to the general
public will increase customer satisfaction.
Non-Functional Testing
Some of the important and commonly used non-functional testing types are
discussed below.
Performance Testing
• Network delay
• Client-side processing
• Database transaction processing
• Load balancing between servers
• Data rendering
Load Testing
Most of the time, load testing is performed with the help of automated tools such
as Load Runner, AppLoader, IBM Rational Performance Tester, Apache JMeter,
Silk Performer, Visual Studio Load Test, etc.
Virtual users (VUsers) are defined in the automated testing tool and the script is
executed to verify the load testing for the software. The number of users can be
increased or decreased concurrently or incrementally based upon the
requirements.
Stress Testing
The aim of stress testing is to test the software by applying the load to the system
and taking over the resources used by the software to identify the breaking point.
This testing can be performed by testing different scenarios such as −
Usability testing is a black-box technique and is used to identify any error(s) and
improvements in the software by observing the users through their usage and
operation.
Nigel Bevan and Macleod considered that usability is the quality requirement that
can be measured as the outcome of interactions with a computer system. This
requirement can be fulfilled and the end-user will be satisfied if the intended goals
are achieved effectively with the use of proper resources.
Molich in 2000 stated that a user-friendly system should fulfill the following five
goals, i.e., easy to Learn, easy to remember, efficient to use, satisfactory to use,
and easy to understand.
In addition to the different definitions of usability, there are some standards and
quality models and methods that define usability in the form of attributes and sub-
attributes such as ISO-9126, ISO-9241-11, ISO-13407, and IEEE std.610.12, etc.
UI vs Usability Testing
On the other hand, usability testing ensures a good and user-friendly GUI that can
be easily handled. UI testing can be considered as a sub-part of usability testing.
Security Testing
Security testing involves testing a software in order to identify any flaws and gaps
from security and vulnerability point of view. Listed below are the main aspects
that security testing should ensure −
• Confidentiality
• Integrity
• Authentication
• Availability
• Authorization
• Non-repudiation
• Software is secure against known and unknown vulnerabilities
• Software data is secure
• Software is according to all security regulations
• Input checking and validation
• SQL insertion attacks
• Injection flaws
• Session management issues
• Cross-site scripting attacks
• Buffer overflows vulnerabilities
• Directory traversal attacks
Portability Testing
Portability testing includes testing a software with the aim to ensure its reusability
and that it can be moved from another software as well. Following are the
strategies that can be used for portability testing −
Valid Test cases: Valid test cases for the above can be any value entered
greater than 17 and less than 57.
• Enter the value- 18.
• Enter the value- 19.
• Enter the value- 37.
• Enter the value- 55.
• Enter the value- 56.
Invalid Testcases: When any value less than 18 and greater than 56 is
entered.
• Enter the value- 17.
• Enter the value- 57.
Single Fault Assumption: When more than one variable for the same
application is checked then one can use a single fault assumption.
Holding all but one variable to the extreme value and allowing the
remaining variable to take the extreme value. For n variable to be
checked:
Maximum of 4n+1 test cases
Problem: Consider a Program for determining the Previous Data.
Input: Day, Month, Year with valid ranges as-
1 ≤ Month≤12
1 ≤ Day ≤31
1900 ≤ Year ≤ 2000
Design Boundary Value Test Cases.
Solution: Taking the year as a Single Fault Assumption i.e. year will be
having values varying from 1900 to 2000 and others will have nominal
values.
Test Cases Month Day Year Output
Taking Day as Single Fault Assumption i.e. Day will be having values
varying from 1 to 31 and others will have nominal values.
The idea and motivation behind BVA are that errors tend to occur near
the extremes of the variables. The defect on the boundary value can be
the result of countless possibilities.
Example-1:
Let us consider an example of any college admission process. There is a
college that gives admissions to students based upon their percentage.
Consider percentage field that will accept percentage only between 50
to 90 %, more and even less than not be accepted, and application will
redirect user to an error page. If percentage entered by user is less than
50 %or more than 90 %, that equivalence partitioning method will show
an invalid percentage. If percentage entered is between 50 to 90 %, then
equivalence partitioning method will show valid percentage.
Example 2:
Let us consider an example of an online shopping site. In this site, each of
products has a specific product ID and product name. We can search for
product either by using name of product or by product ID. Here, we
consider search field that accepts only valid product ID or product name.
Let us consider a set of products with product IDs and users wants to
search for Mobiles. Below is a table of some products with their product
Id.
Product Product ID
Mobiles 45
Laptops 54
Pen Drives 67
Keyboard 76
Headphones 34
If the product ID entered by user is invalid then application will redirect
customer or user to error page. If product ID entered by user is valid i.e.
45 for mobile, then equivalence partitioning method will show a valid
product ID.
Example-3 :
Let us consider an example of software application. There is function of
software application that accepts only particular number of digits, not
even greater or less than that particular number.
Consider an OTP number that contains only 6 digit number, greater and
even less than six digits will not be accepted, and the application will
redirect customer or user to error page. If password entered by user is
less or more than six characters, that equivalence partitioning method
will show an invalid OTP. If password entered is exactly six characters,
then equivalence partitioning method will show valid OTP.
Example 4:
Consider the program for the determination of nature of roots of a quadratic equation as.
Identify the equivalence class test cases for output and input domains.
Output domain equivalence class test cases can be identified as follows:
Cause Effect Graphing based technique is a technique in which a graph
is used to represent the situations of combinations of input conditions.
The graph is then converted to a decision table to obtain the test cases.
Cause-effect graphing technique is used because boundary value
analysis and equivalence class partitioning methods do not consider the
combinations of input conditions. But since there may be some critical
behaviour to be tested when some combinations of input conditions are
considered, that is why cause-effect graphing technique is used.
Steps used in deriving test cases using this technique are:
1. Division of specification:
Since it is difficult to work with cause-effect graphs of large
specifications as they are complex, the specifications are divided
into small workable pieces and then converted into cause-effect
graphs separately.
2. Identification of cause and effects:
This involves identifying the causes(distinct input conditions)
and effects(output conditions) in the specification.
3. Transforming the specifications into a cause-effect graph:
The causes and effects are linked together using Boolean
expressions to obtain a cause-effect graph. Constraints are also
added between causes and effects if possible.
4. Conversion into decision table:
The cause-effect graph is then converted into a limited entry
decision table. If you’re not aware of the concept of decision
tables, check out this link.
5. Deriving test cases:
Each column of the decision-table is converted into a test case.
Basic Notations used in Cause-effect graph:
Here c represents cause and e represents effect.
The following notations are always used between a cause and an effect:
1. Identity Function: if c is 1, then e is 1. Else e is 0.
• Coverage metrics
• Statement coverage: all statements in the programs should
be executed at least once
• Branch coverage: all branches in the program should be
executed at least once
• Path coverage: all execution paths in the program should
be executed at least once
• The best case would be to execute all paths through
the code
Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
ENDIF
If P > 50 THEN
Print “P Large”
ENDIF
Statement Coverage (SC):
To calculate Statement Coverage, find out the shortest number of paths following which all the
nodes will be covered. Here by traversing through path 1A-2C-3D-E-4G-5H all the nodes are
covered. So by traveling through only one path all the nodes 12345 are covered, so the Statement
coverage in this case is 1.
Branch Coverage (BC):
To calculate Branch Coverage, find out the minimum number of paths which will ensure covering
of all the edges. In this case there is no single path which will ensure coverage of all the edges at
one go. By following paths 1A-2C-3D-E-4G-5H, maximum numbers of edges (A, C, D, E, G and H)
are covered but edges B and F are left. To covers these edges we can follow 1A-2B-E-4F. By the
combining the above two paths we can ensure of traveling through all the paths. Hence Branch
Coverage is 2. The aim is to cover all possible true/false decisions.
Path Coverage (PC):
Path Coverage ensures covering of all the paths from start to end.
All possible paths are-
1A-2B-E-4F
1A-2B-E-4G-5H
1A-2C-3D-E-4G-5H
1A-2C-3D-E-4F
So path coverage is 4.
Thus for the above example SC=1, BC=2 and PC=4.
Statement Coverage
if (x < y) { B0 (x < y)
x = 5 * y; Y N
x = x + 3;
} x = 5 * y B1 B2 y = 5
else x = x + 3
y = 5;
x = x+y;
x = x+y B3
• Select a test set T such that by executing program P for each test case
d in T, each edge of P’s control flow graph is traversed at least once
B0
(x < 0)
true false
B1 Test set {x=−1} does not
x := -x execute this edge, hence, it
does not give branch coverage
assignAbsolute(int x)
{ Consider this program segment, the test set
if (x < 0) T = {x = −1} will give statement coverage,
x := -x; however not branch coverage
z := x;
}
B0
Control Flow Graph: (x < 0)
true false
B1 Test set {x = −1} does not
x := -x execute this edge, hence, it
does not give branch coverage
B2
z := x
Path Coverage
• Select a test set T such that by executing program P for
each test case d in T, all paths leading from the initial to
the final node of P’s control flow graph are traversed
Path Coverage
B0
areTheyPositive(int x, int y)
(x >= 0)
{
if (x >= 0) true false
print(“x is positive”); B1 B2
else print(“x is p”) print(“x is n”)
print(“x is negative”);
if (y >= 0)
print(“y is positive”); B3
else (y >= 0)
print(“y is negative”); true false
} B4 B5
Test set: print(“y is p”) print(“y is n”)
T2 = {(x = 12,y = − 5), (x = − 1,y = 35)}
gives both branch and statement B6
coverage but it does not give path coverage
return
Set of all execution paths: {(B0,B1,B3,B4,B6), (B0,B1,B3,B5,B6), (B0,B2,B3,B4,B6),
(B0,B2,B3,B5,B6)}
Test set T2 executes only paths: (B0,B1,B3,B5,B6) and (B0,B2,B3,B4,B6)
Path Coverage
B0
areTheyPositive(int x, int y)
(x >= 0)
{
if (x >= 0) true false
print(“x is positive”); B1 B2
else print(“x is p”) print(“x is n”)
print(“x is negative”);
if (y >= 0)
B3
print(“y is positive”);
else (y >= 0)
print(“y is negative”); true false
} B4 B5
print(“y is p”) print(“y is n”)
Test set:
T1 = {(x=12,y=5), (x=−1,y=35),
B6
(x=115,y=−13),(x=−91,y=−2)}
return
gives both branch, statement and path
coverage
Cyclomatic Complexity
• Cyclomatic complexity of a code section is the quantitative measure of the number of linearly
independent paths in it.
• It is a software metric used to indicate the complexity of a program.
• It is computed using the Control Flow Graph of the program.
• The nodes in the graph indicate the smallest group of commands of a program, and a directed
edge in it connects the two nodes i.e. if second command might immediately follow the first
command.
• M=E–N+2
• where,
E = the number of edges in the control flow graph
N = the number of nodes in the control flow graph
Cyclomatic Complexity
• Steps that should be followed in calculating cyclomatic
complexity and test cases design are:
• Do not use a coding style that is too clever or too difficult to understand
• Do not use an identifier for multiple purposes
• The code should be well-documented
• The length of any function should not exceed 10 source lines
• Do not use goto statements
• Do not do hard coding