Unit 4
Unit 4
SOFTWARE
TESTING
What is Testing?
Many people understand many definitions of testing-
3. EARLY TESTING
The sooner we start the testing activities the better we can utilize the available time. As
soon as the initial products, such the requirement or design documents are available, we
can start testing. It is common for the testing phase to get squeezed at the end of the
development lifecycle, i.e. when development has finished, so by starting testing early, we
can prepare testing for each level of the development lifecycle.
Another important point about early testing is that when defects are found earlier in the
lifecycle, they are much easier and cheaper to fix. It is much cheaper to change an
incorrect requirement than having to change a functionality in a large system that is not
working as requested or as designed!
4. DEFECT CLUSTERING
During testing, it can be observed that most of the reported defects are related to small number of modules
within a system. i.e. small number of modules contain most of the defects in the system. This is the application of
the Pareto Principle to software testing: approximately 80% of the problems are found in 20% of the modules.
If the system built is unusable and does not fulfil the user’s needs and expectations then finding and fixing defects
does not help.
• Other principles to note are:
1. Unit Testing
2. Integration Testing
3. System Testing
Unit Testing
• Unit testing is a method by which individual units of source code
are tested to determine if they are fit for use.
• A unit is the smallest testable part of an application like
functions, classes, procedures, interfaces.
• Unit tests are basically written and executed by software
developers to make sure that code meets its design and
requirements and behaves as expected.
• The goal of unit testing is to segregate each part of the program
and test that the individual parts are working correctly.
• This means that for any function or procedure when a set of
inputs are given then it should return the proper values. It
should handle the failures gracefully during the course of
execution when any invalid input is given.
Advantages of Unit Testing
1. Issues are found at early stage. Since unit testing are carried out by
developers where they test their individual code before the integration. Hence
the issues can be found very early and can be resolved then and there without
impacting the other piece of codes.
2. Unit testing helps in maintaining and changing the code. This is possible by
making the codes less interdependent so that unit testing can be executed.
Hence chances of impact of changes to any other code gets reduced.
3. Since the bugs are found early in unit testing hence it also helps in reducing
the cost of bug fixes. Just imagine the cost of bug found during the later stages
of development like during system testing or during acceptance testing.
4. Unit testing helps in simplifying the debugging process. If suppose a test fails
then only latest changes made in code needs to be debugged.
Component Testing
• It is also called as module testing.
• The basic difference between the unit testing and
component testing is in unit testing the developers test
their piece of code but in component testing the whole
component is tested.
• There are problems associated with testing a module
in isolation.
• How do we run a module without anything to call it, to
be called by it or, possibly, to output intermediate
values obtained during execution?
Stubs and drivers
• In such case the missing software is replaced by Stubs and Drivers and simulate
the interface between the software components in a simple manner.
• Driver: Driver
Test B
E F G
Test C
Test
Test D A, B, C, D,
E, F, G
Test E
Test F
Test G
Advantages and Disadvantages
• The only advantage is that – for a small system
this will be ideal integration testing technique.
• The disadvantages is that – you would have to
wait for all the modules to be integrated, so
there will be quite a lot of delay.
• Errors are identified at a very late stage and it
is very hard to identify the fault.
Incremental Integration
• The incremental approach means to first
combine only two components together and
test them. Remove the errors if they are there,
otherwise combine another component to it
and then test again, and so on until the whole
system is developed.
• In this, the program is constructed and tested
in small increments, where errors are easier to
isolate and correct.
A T1
T1
A
T1 T2
A B
T2
T2 B T3
T3
B C
T3 T4
C
T4
D T5
E F G
Test
Test A Test A, B, C, D A, B, C, D,
E, F, G
Test E
E F G
Test B, E, F
Test F
Test C Test
A, B, C, D,
E, F, G
Strategy
B C D
Test A
E F G
Test A,B,C, D
Test E
Test
Test B, E, F A, B, C, D,
Test F E, F, G
Test D,G
Test G
Sandwich/ Bidirectional Testing
• It is performed initially with the use of stubs &
drivers.
• Drivers are used to provide upstream connectivity
while stubs provide downstream connectivity.
• Driver is a function which redirects the requests to
some other component .
• Stubs simulate the behavior of a missing
component.
• After testing the functionality of the integrated
components, stubs & drivers are discarded.
Guidelines on selection of integration
method:
S.No Factors Suggested Integration Method
1. Alpha Testing
2. Beta Testing
3. Acceptance Testing
Alpha Testing
• This test takes place at the developer’s site.
• Alpha testing is testing of an application when development is
about to complete. Minor design changes can still be made as a
result of alpha testing.
• Alpha testing is typically performed by a group that is
independent of the design team, but still within the company,
e.g. in-house software test engineers, or software QA engineers.
• Alpha testing is final testing before the software is released to the
general public. It has two phases:
– In the first phase of alpha testing, the software is tested by in-house
developers. They use either debugger software, or hardware-assisted
debuggers. The goal is to catch bugs quickly.
– In the second phase of alpha testing, the software is handed over to the
software QA staff, for additional testing in an environment that is similar
to the intended use.
Beta Testing
• It takes place at customer’s site. It is the system testing
performed by a selected group of friendly customers. It sends
the system to users who install it and use the software in testing
mode., that is not live usage.
• A beta test is the second phase of software testing in which a
sampling of the intended audience tries the product out. (Beta is
the second letter of the Greek alphabet.) Originally, the
term alpha test meant the first phase of testing in a software
development process. The first phase includes unit testing,
component testing, and system testing. Beta testing can be
considered “pre-release” testing.
• The goal of beta testing is to place your application in the hands
of real users outside of your own engineering team to discover
any flaws or issues from the user’s perspective that you would
not want to have in your final, released version of the application.
Differences between Alpha and Beta Testing
During alpha testing, developers records During beta testing, customer records all
errors and usage problems. problems and submits report to the
developer for modifications at regular
intervals.
Acceptance Testing
• It is a type of testing carried out in order to verify if the
product is developed as per the standards and specifies
criteria and meets all the requirements specified by
customer.
• Thus, acceptance testing is the system testing to determine
whether to accept or reject the delivery of the system.
• The goal of acceptance testing is to establish confidence in
the system.
• Acceptance testing is most often focused on a validation
type testing.
Regression Testing
• It is a type of testing carried out to ensure that
changes made in the fixes are not impacting the
previously working functionality.
• The main aim of regression testing is to make
sure that changed component is not impacting
the unchanged part of the component.
• It means re-testing an application after its code
has been modified to verify that it still functions
correctly.
Software Testing Strategies
• It provides a road map for the software developers,
quality assurance organizations and the customer.
• Common characteristics of software testing
strategies include the following:
– Testing begins at the module level and works outward
toward the integration of the entire system.
– Different testing techniques are appropriate at different
times.
– Testing is conducted by developers and for large
projects, by an independent test group.
Types of Testing Strategy
1. Top down Strategy
It is an approach where modules are developed
and tested starting at the top level of the
programming hierarchy and continuing with the
lower levels.
2. Bottom up Strategy
It is opposite of top down method. This process
starts with building and testing the low level
modules first, working its way up the hierarchy.
White Box testing
• White Box testing is based on the inner
workings of an application and revolves around
internal testing. The term "whitebox" was used
because of the see-through box concept. The
clear box or whitebox name symbolizes the
ability to see through the software's outer shell
(or "box") into its inner workings.
• One of the basic goal of white box testing is to
verify a working flow for an application.
White Box Testing
• White-box testing is also called as:
-Structural testing
-Code Based Testing
-Clear testing
-Open testing
- Glass box testing
How do you perform White Box Testing?
For this 4
definition, two
DU pairs: 5
DEF(1) := {s}, USE(1) :=
1-7, 1-8 DEF(2) := {x}, USE(2) :=
DEF(3) := , USE(3) := {x,y} 6
DEF(4) := {x}, USE(4) := {x}
DEF(5) := {y}, USE(5) := {y} 7 8
DEF(6) := , USE(6) := {x,y}
DEF(7) := {s}, USE(7) := {s,x,y} 9
DEF(8) := {s}, USE(8) := {s,x,y}
10
Data-flow-based Testing
• Identify all DU pairs and construct test cases that
cover these pairs
– Several variations with different “relative strength”
• All-DU-paths: For each DU pair (n1,n2) for x, exercise
all possible paths n1, n2 that are clear of a definition
of x
• All-uses: for each DU pair (n1,n2) for x, exercise at
least one path n1 n2 that is clear of definitions of x
Data-flow-based Testing
2. Generate the test cases using the equivalence classes identified in the
previous step. This is performed by writing test cases covering all the valid
equivalence classes. Then a test case is written for each invalid
equivalence class so that no test contains more than one invalid class. This
is to ensure that no two invalid classes mask each other.
Most of the time, equivalence class testing defines classes of the input domain.
However, equivalence classes should also be defined for output domain. Hence, we should
design equivalence classes based on input and output domain.
We should test different types of invalid inputs in order to get more errors. As an example
for a program that is supposed to accept any number between 1 and 99, there are
at least four equivalence classes from input side. The classes are:
1. Any number between 1 and 99 is valid input
2. Any number less than 1. This include 0 and all negative number.
3. Any number greater than 99
4. If it is not a number, it should not be accepted.
E.g. Life Insurance Premium Rates
Age Group Additional Premium
Under 35 $1.65
35-59 $2.87
60+ $6.00
Based on the age group, an additional monthly premium has to be paid as base
premium($0.50) + additional premium.
Now, The equivalence partitions that are based on the age are:
1. Below 35 yrs of age (Valid i/p)
2. Between 35 & 59 yrs of age (Valid i/p)
3. Above 60 yrs of age (Valid i/p)
4. Negative age (Invalid i/p)
5. Age as 0 (Invalid i/p)
6. Age as any three digit number (Invalid i/p)
Example
Consider a program for the determination of the nature of
roots of a quadratic equation. Its input is a triple of positive
integers (say a,b,c) and values may be from interval [0,100].
The program output may have one of the following words.
Identify the equivalence class test cases for output & input
domains.
Solution
5.State/Graph Based Testing
state: abstract situation in the life cycle of a system entity (for instance, the
contents of an object)
– Endurance testing - is done to make sure the software can handle the
expected load over a long period of time.
Focusing on demonstrating how work product meets all requirements, IEEE recommends
three specialist roles in a walkthrough:
1. Leader
2. Recorder
3. Author
Walkthrough Process
Author describes the artifact to be reviewed to reviewers during the meeting.
Reviewers present comments, possible defects and improvement suggestions to the
author. Recorder records all defects & suggestion during walkthrough meeting. Based
on reviewer comments, author performs any necessary rework of the work product ,
if required. Leader normally monitors overall walkthrough meeting activities as per
the defined company process & responsibilities for conducting the reviews.
Generally, the leader performs monitoring activities, commitment against action
items etc.
During the walkthrough session, problems are not resolved. Rather, the goal is to
discover & make note of problem areas. The problems are resolved by the reviewer,
once the walkthrough session is over. A follow-up meeting or follow-up memo should
be used which will inform the reviewers of the actions taken. The review may work
with one or more reviewers to solve problems but it is the reviewer's responsibility
to ensure that the problems noted during the walkthrough are solved.
Advantages of Walkthrough
• By involving team members in the walkthrough process, project team
communication is improved.
• It is an excellent education medium for new team members.
• If the bugs are found in the earlier part of the life cycle of a product, they
are cheaper and easier to fix.
• When someone other than the author looks at the design or code, they
are likely to find the mistakes which the author might have overlooked.
• It gives an opportunity to other team members to learn from someone
else’s code.
• When the software product is explained to an audience, the author gets
an opportunity to review his own program.
• When conducted in a proper manner, they save time and improve quality
of the software product.
Limitations of Walkthrough
• The limitation of walkthrough is that –
they take time. Not only the person who is
actively involved on the project, but also other
people have to devote their precious time for
walkthrough.
Code Inspection
• It is a formal group review designed to identify
problems as close to their point of origin as
possible.
• It is used to improve the quality of product
and to improve productivity.
Objectives of Inspection Process
• Find problems at the earliest possible point in the s/w
development process.
• Verify that the work product meets its requirements.
• Ensure that the work product has been presented
according to predefined standards.
• Provide data on product quality and process
effectiveness.
• Builds technical knowledge & skills among team
members by reviewing the output of other people.
• Increases the effectiveness of software testing.
IEEE recommends following roles:
1. Inspection Leader
2. Recorder
3. Reader
4. Author
5. Inspector
Inspection Process
• Following are the various phases of inspection
process:
– Planning
– Overview
– Preparation
– Examination meeting
– Rework and followup
Advantages of code inspection
1. Lists all potential design flows that can make
s/w code less maintainable and costly to
develop
2. Indicates all defects that otherwise are difficult
to fix during normal operational testing &
usage.
3. A detailed error feedback is provided to
individual programmers. It makes easier for
them to make changes in the code.
Compliance with Design and Coding
Standards
• Though at initial stages it seems like a burden to follow
standard, its advantages become visible once the
software grows to few thousand lines spanning few
hundred files.
• Some of the advantages are:
– Programmer feels comfortable with the code written by
others, as it is similar to what he himself would have written.
– Person joining the group at later stage can pickup the code
easily. (once he is familiar with the standards)
– If care is taken to define the standard in such a way that it
avoids problematic idioms, then silly mistakes can be avoided.
• The problem with having standard is that it takes
time to get acquainted with it. If care is not taken
during this transition period, then the resulting code
will be a mix of standard and programmer’s natural
style. This can be avoided by having regular code
review sessions.
• Good s/w development organizations usually
develop their own coding standards & guidelines
depending on what best suits their organization &
the type of products they develop.
• The following are some representative coding
guidelines recommended by many s/w development
organizations.
– Do not use a coding style that is too difficult to understand.
– Avoid obscure side effects.
– 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.
END OF UNIT-4