Block-2 Design and Testing
Block-2 Design and Testing
l@J
~ Ignou
~=
Indira Gandhi National Open University
BCS-051
Introduction to
School of Computer and Information Sciences.
Software Engineering
Roles for Technology Stream (Development) in Roles for Project Management Stream
IT Product Development Industry (Development) In IT Services Industry
System Senior
Software
Engineer
, Principal
. Engineer
Product
Architect Engineer
Trainee ':+ System
Engineer
System
Engineer'
Technology
Analyst
Director
••
Senior Product
Senior
Project
••
Technology
Architect Lead
Manager
••
Senior Vice CXO
COO/CEO/CTO)
••
Group
Project
Senior
Vice
President
Manager President
System Senior
System Technology
Engineer System Analyst
Engineer, Engineer
Trainee
••
Principal
Architect
Vice
President
Senior
Vice
CXO
COO/CEO/CTO)
President
System
Engineer
Senior
System
Engineer
Technology
Analyst
~ystem
Engineer
Trainee
IL.
I)
System
Engineer
Senior
System
Engineer
Technology
- Analyst
SeniorQA
Architect
QAArchitect
.- SeniorQA
Lead
QALead Princ,lp~1
Consultant
Senior
Consultant ~
Consultant
•• Associate
Consultant
•• •• Senior
•••
Vice Senior
Principal Vice Vice CXO
President Vice I~
Architect President COO/CEO/CTO)
President President
I1
-
•
-
"Education is a liberating force, and in
our age it is also a democratising force,
cutting across the barriers of caste and
class, smoothing out inequalities imposed
by birth and other circumstances. "
- Indira Gandhi
• BCS-OSl
.~~J)llgnou THE PEOPLE'S
. UNIVERSITY
INTRODUCTION TO
SOFTWARE
Indira Gandhi National Open University ENGINEERING
School of Computer and Information Sciences
"
-.
;
Block ".
2
DESIGN AND TESTING
UNIT 1
.Function Oriented Design 5
UNIT 2
Object Oriented Design 15
UNIT 3
Software Testing Techniques . 25
UNIT 4
Development and Execution of Test Cases 41
I
PROGRAMME DESIGN COMMITTEE
Prof. Manohar Lal • Prof. Atvind Kalia, Dept. of CS Sh. Akshay Kumar
SOCIS, IGNOU, New Delhi HP University, Shimla Associate Prof.
SOCIS, IGNOU, New Delhi
Prof. H. M: Gupta Prof. Anju Sahgal Gupta
Dept. of Elect. Engg. SOH, IGNOU, New Delhi Or. P. K. Mishra, AssociateProf.
lIT, Delhi Dept. of CS, BHU, Varanasi
Prof. Sujatha Verma
Prof. M. N. Doja, Dept. of 'CE SOS, IGNOU, New Delhi Or. P. V. Suresh, Associate Prof.
Jamia MiIlia, New Delhi SOCIS, IGNOU, New Delhi
Prof. V. Sundarapandian
Prof. C. Pandurangan IITMK, Trivandrum Sh. V. V. Subrahmanyarn
Dept. of CSE, lIT, Chennai Associate Prof.
Prof. Dharamendra Kumar
"
SOCIS, IGNOU, New Delhi
Prof. I. Ramesh Babu ,Dept. of CS, GJU, Hissar
Dept. ofCSE Sh. M. P. Mishra, Asst. Prof.
Prof. Vikram Singh
Acharya Nagarjuna University SOCIS, IGNOU, New Delhi
Dept. of CS, CDLU, Sirsa
Nagarjuna Nagar (AP)
Or. Naveen Kumar, Reader
Sh. Shashi Bhushan
Pref. N. S. Gill SOCIS, IGNOU, New Delhi
Associate. Prof.
Dept. Of CS, MDU, Rohtak
SOCIS, IGNOU, New Delhi Dr. Subodh Kesharwani, Asst. Prof.
SOMS, IGNOU, New Delhi
SOCIS FACULTY
Sh. Shashi Bhushan, Director Prof. Manohar Lal Or. P. V. Suresh
Associate Professor
Sh. Akshay Kumar Sh ..V. V. Subrahmanyam
Associate Professor Associate Professor Or. Naveen Kumar
Reader
Sh. M. P. Mishra Or. Sudhansh Sharrna
Asst. Professor Asst. Professor
PREPARATION TEAM
Content Editor: Block Writers: Unlt3
Or. S. R. N. Reddy Units 1, 2 and 4 Ms. Neetu Jain
Dept. ofCSE Sh. Shailesh Kumar Shiva Research Scholar (SOCIS,
Kumar, Research Scholar IGNOU) and Faculty (Amity
IGDTUW
(SOCIS, IGNOU) and Senior University)
New Delhi Technology Architect (Infosys
Language Editor: Technologies)
Print Production
Mr. S. Burman Mr. Tilak Raj Mr. Yash Pal
Dy. Registrar (Publication) Asstt. Registrar (Publication) Section Officer (Publication)
MPDD, IGNOU, New Delhi MPPD. IGNOU, New Delhi MPDD, IGNOU New Delhi
January 2018 (Reprint)
© Indira Gandhi National Open University
ISBN·978·81·266·6611·9
All rights reserved. No part of this work may be reproduced in any form, by mimeograph or any
other means, without permission in writing from the Indira Gandhi National Open University.
Further information about the Indira Gandhi National Open University courses may be obtained
from the University's office at Maidan Garhi, New Delni-t ; 0068.
Printed and published on behalf of the Indira Gandhi National Open University, by
Registrar MPDD, IGNOU, New Delhi .
Printed at: Ankur Offset Pvt. Ltd., A-54, Sector-63, Noida-201307 (U.P.)
I
BLOCK INTRODUCTION
..
I
This block introduces learner to Function Oriented Design (FOD), Object Oriented
Design (OOD), Testing Techniques and Development and Execution of Test Cases .
A typical procedural software system consists of multiple functions that share the same
state and interact. We will look at the various methods for designing a modular function,
. decomposing the function into reusable and loosely coupled" sub functions and its visual
representation. We will also examine the process and best practices for identification and
development of functions. Function oriented design essentially deals with creating
.
"
functions to convert input into the desired output. Function, Function state and
Sub-Function are the key elements of FOD .
Softwar'e design often mimics real-world objects and designs. Many software design
principles, design patterns and techniques are inspired usually by nature. Software
architects find it natural tlS"model software components based on their real-world
counterparts. The role of the architects and designers are mainly involved in marrying the
objects in the software world with the objects in the real-world. This is also done in part
to make the end-user accustomed to the software and make their transition from the
real-world to, virtual work easier and friendlier. Complex modeling, Abstraction,
Hierarchy Modeling, Reusability, Extensibility and Flexibility are some of the motivating
factors for having the design using Object-Oriented concepts.
Software testing is a very important phase in Software Development Life Cycle (SDLC).
It is a repetitive process that helps identify not only the errors in the developed
application but also corrects those errors. One may think that finding errors is a simple
task. Then why would we need to pay importance to testing. In this unit, we will discuss
the different aspects and iniportance of testing. Even. though testing may seem easy, it is
not an easy tas~ and needs a strategic and systemised approach to ensure suitability.
Preparation of test cases is a very important step for effective testing of any software. A
testing team which is different from the development team will test the software. One of
the' base document for preparing test cases is SRS. It can never be claimed that the
software is error free as any software can be claimed as error free software only when the
software su cess' ully runs until it is withdrawn due to reasons that are not pertaining to
itself.
This block consists of four units andis organized as follows:
Unit 1 deals with FOD. It covers concepts as well as other issues associated with FOD
such as Cohesion, Coupling, etc.
Unit 2 deals with OOD. It covers concepts as well as other issues associated with
problem domain static objects, application logic objects, etc.
Unit 3 deals with Software Testing Techniques. It covers various testing techniques such
as White Box Testing, Black Box Testing, etc. ,
Unit 4 deals with Development and Execution of Test Cases. It covers topics such as test
case preparation and their execution.
"
;'
I
UNITl FUNCTION ORIENTED DESIGN
Structure
1.0 Introduction
1.1' Objectives
1.2 Constructing a Solution to a Problem
.
"
1.2.1 Solution ~esign Principles
1.2.2 Solution Design Methods in Function Oriented Design
1.3 Identifying Components and their Interaction
1.3.1 Identification Process
1.3.2 Com~o~~nt and Stage Mapping
1.4 Visualizing the Solution
1.4.1 Context Diagram
'1.4.2 Data Flow Diagram (DFD)
1.6 'Summary
1.0 INTRODUCTION
This unit details the' concepts of function oriented design and the modeling techniques for
the same. A tYJlfcal procedural software system consists of multiple functions that share
the same state ana interact. We will look at the various methods for designing a modular
function, decomposing the function into reusable and loosely coupled sub functions and
its visual representation. We will also examine the process and best practices for
identification and development of functions
Function oriented design essentially deals with creating functions to convert input into
the desired output.
• Function state: It's the data on which a function operates. For example a
getEmployeeDetails function would require the employee state stored in the
database. In a function oriented design, the state is centrally stored and is
accessible to all functions.
• Sub Function: The main function can be further broken down into smaller
re-usable units of code or sub-functions or sub-routines. For instance
getEmployeeDetails main function can further invoke
getlimployeeContactlretails and getEmployeePersonaLDetails sub-routines.
The following are the key features of the function oriented design:
• Function state sharing: The state of the system is shared among various
functions. For instance, in the above example, the state of person's details is
shared among all the functions including UpdatePersonPersonalDetails,
UpdatePersonAddressDetails and Updatel'ersorrContactlretails.
The following table explains the concepts associated with Function Oriented Design:
1.1 OBJECTIVES
After going through this unit, you should be able to
I
Function Oriented
1.2.1 Solution Design Principles Design
Before looking at the actual methods, we will first look at'the driving principles on which
these methods are based. This will help us to appreciate the prin~iples of design better:
• Top down decomposition: When we adopt this design principle, we
iteratively and sometimes recursively decompose the problem from the top.
This is often a top-down approach for creation of a solution to a problem. In
function oriented design, we break the main function into smaller sub-
functions which are both modular and reusable.
.
"
• 'Divide and conquer: Using this design, we break down the problem
functionally into smaller sub-problems. Each sub-problem is then
independently solved. For instance, a simple binary search function would
first break the problem space into two equal sub-problems and then solve
each of thos sub-problems individually .
.-' :/
. "/' In this design methodology, detailed design specifications would be developed for
each of the functions to come up with the architecture of the system. These
specifications can later be used for the actual implementation in a given
programming language.
The following are the main elements of a specification document:
• Detailed problem specification
• Key data types
• Specification for all functional modules
• Known constraints
"
• Significant architecture and design decisions
Check Your Prog~ess 1
.\ (1) In function oriented design the state is stored .
(2) design principle involves breaking down a single problem
into smaller sub-problems.
(3) Data flow diagram is often designed in the stage.
I
Function Oriented
1.3.2 .Component and Stage Mapping Design
The following table indicates the component/association identified at each level of the
process:
Highest-integers
End User
(1) Start with the system specifications document. Identify each high level
" function and model it as a circle in DFD.
(2) Identify all the input data to this function and depict it in the DFD.
(3) Identify all the output data to this function and depict it in the DFD .
.v:.: .Further,
refining can be done by structurally decomposing the high-level function
, circles into smaller modular sub-functions till each sub-function represents a
distinct reusable task implementation.
Example of a DFD
Let us' take an example for "finding largest number" scenario given for the
contextual diagram. In the context diagram "Find largest number" is a high level
abstract for the function which calculates the largest number. However, internally
this function performs two more tasks: '-,
Create- Sort-the-list
number-list
Input-numbers
End User
Find
Largest-number
I
. Functional Independence Function Oriented
Design
The mode led functions should be independent in terms of the tasks they perform.
This would help in .
• Cost: The functions should aim to reduce the overall cost in terms of
maintainability and extensibility.
Cohesion '
Types of Cohesion
.
, Function updateEmployee (int ernpld, String newname) {
The above function performs a single task of"G~ting a connection. The internal
variables and logic is completely concerned with opening a connection. Strong
internal cohesion is always considered a best practice as it helps in re-usability and
maintainability.
Coupling'
The design thumb rule is, to have loose coupling so that, each of the individual
modules and its internal structure can be changed with greater impact on other
modules .
. Types of Coupling
12
I
/
• Data coupling: If two modules are coupled by a function parameter it Function Oriented
Design
is said to be data coupling. This is an example of loose coupling. For
.instance, a function call through the-specified argument forms a
standard data coupling.
'Connascence .
Two modules are said to be in connascence if a change in the first module requires
a mandatory change in the second module for ensuring overall functionality. This
is also a form of a very tightly coupled modules.
1.7 AtlS••
~ERS TO CHECK YOUR PROGRESS
Check Your Progress 1
(1) Centrally
(1) Rectangle
(3) Cohesion
13
Design and Testing
1.8 FURTHER READINGS
Reference Books
Peretz Shoval: Functional and Object Oriented Analysis and Design: An Integrated
Methodology.
Reference Websites
http://en. wikipedia.orglwikilCoupling (computer programming)
" http://en.wikipedia.orglwikilCohesion (computer science)
14
I
, UNIT 2 OBJECT ORIENTED DESIGN
. Structure
,. 2.0 Introduction
2.1 Objectives
2.2 Identification of Problem Domain Static Objects
.
"
2.2.1 Static Objects
2.2,2 Problem Domain - Static Object Mapping Deep Dive
2.0 INTRODUCTION
This Unit explains the design principles related to object oriented design. We will look at
some of the key object oriented design concepts and later examine the detailed process of
specifying and identifying problem domain static objects.
Software design often mimics real-world objects and designs. Many software design
principles, design patterns and techniques are inspired usually by nature. Software
architects find it natural to model software components based on their real-world
counterparts. The role of the architects and designers are mainly involved in marrying the
objects in the software world with the objects in the real-world. This is also done in part
to make the end-user accustomed to the software and make their transition from the real-
world to virtual work easier and friendlier. For instance, a typical grocery shopping
involves grocery items, shopping cart and purchase. If this process is modelled in the
software world, it would involve almost similar objects including ShoppingCart object
and checkout process.
The process of modeling also involves identification of var-iousproperties of the objects,
their association, data flow, etc.
The following are the key motivating factors for having the design using object-oriented
concepts:
.
" • Contract specification: Object-oriented design also allows us to specify the
clear contract for an object via interfaces. All implementations of this
interface must adhere to the contract enabling controlled extension. For
instance, the behaviour of a product can be defined in an interface. All
product variants that irnplement the interface would provide the variant
specific implementation of the behaviour methods.
• Information abstraction: Each object has a strict policy to hide its internal
state forprivate variables and provides public methods for accessing data.
Let's look at some of the core features of the class which are instantiated by objects:
• Attributes: These are the properties of the class. During instantiation of the
class, an object provides specific values for attributes and this is often
referred to as "state" of the object. In Figure 2.1, deptNo, deptName are the
attributes of Dept class and empNo, empName, and empDetai1s are the
attributes of Employee class.
When a class is instantiated by objects, each object has its own value for all the variables.
16
I
Object Oriented Design .
Oept
+ getDeptNoO: int
+ getDeptNameO: String
..
1
'
*
.
Employee
vt,
. ,
,..
'/ :/
;.1"
- emptNo: int
- emptName: String
- empDetails: String
+ getEmptNoO: int
+ getEmptNameO: String
+ getEmpDetailsO: String
,
• know generic guidelines and thumb rules for specifying and identifying
problem domain static objects, .
• know generic guidelines and best practices for identification and design of
objects.
4. Librarian makes an entry 'in his register for the book against student and
issues the book.
If we were to identify the static objects in this use case, we can identify these objects:
• Student
"" • Library
• Book'
• Librarian
• TransactionRegistry
Though "Library rack" constitutes a noun, it is ignored as it is irrelevant for the core use
case.
, (iT'
Check Your Progress 1
,-
(2) Contract and behavior specification are given by .
I
*'
Public class PrimeNumberChecker {
Object Oriented Design
'ffhe class level variable to hold the input value for processing
Private int inputNumber;
r
The method takes an integer value and checks if the number is a prime number or not
Returns true if number is prime else returns false
"
*'
Public Boolean isPrime (int no) {
If (no==nullll· !isNumber(no)) return false;
Return checkPrirne(no);
4. Once the shopping is complete, the user can proceed to the checkout
Let's consider two classes for modelling: ShoppingCart and Cartltem. Figure 2.2
provides specification for both the classes including the attribute and operation definition
and depicts the relationship between them. The relationship specified is
"one-to-many" to indicate that one shopping cart can contain multiple cart items.
ShopplngCart
- cartNamd: String
- cartltems: List
+ getCartNameO: String
+ addToCart(Cartltemitem): void
1 /
*
Cartltem
- itemName: String
,. - itemValue: Money
- itemQuantity: int
+ qetlternvaluef): Money
+ getltemNameO: String
+ getltemQuantityO: int
1
Design and Testing
2.4 APPLICATION LOGIC OBJECTS
In a typical multi-tiered architecture, the application logic or the business logic will be in .
the business application layer. The layered architecture provides "separation of concerns"
so that objects in individual layers can be independently modified and extended due to
loose coupling.
The business application layer consists of a number of objects such as, Business Objects
(BOs), Data Access Objects (DAOs), Service facade, delegates, bean objects, etc.
Normally, the application logic would be part of business objects.
2.4.1 Motivation of Application Logic Objects
'The following are some of the key motivating factors for creating separate application
'logic objects: '
v'
• Centralised access to application logic,
• Loose coupling and increased testability,
• Layered separation of application logic concern, and
• Reusability of application logic.
\ . 2.4.2 Identification of Application Logic Objects
In a use case, all objects that consist of core application logic arepotential.candidates for
application logic objects. We can summarize the basic qualities for application logic
objects as follows: '
• Owner of core bus~~esslogic,
• Interacts with other application logic objects, and
• Used in application transaction .
2.4.3 Sample Application Logic Objects
Let us consider a banking scenario with the following use case:
Given below is a simple example of a Use cas~ for opening an account:
II (1)
(2)
The user can open an account by providing the details required for opening
an account.
An account could be a savings account or a checking account.
I (3) A savings account should contain a minimurri balance of 10,000 Rupees per
- quartet. If this is not satisfied then a fine of Rs. 500 will be deducted.
(4), Each savings account is linked to only one credit card.
(5) A credit card's credit limit is based on the user's balance in the savings
account for an entire year.
(6) If the user fails to pay the.minimum amount due on the credit card, then the
credit card is authorised to automatically debit the amount from the linked
savings account. The credit card will be automatically blocked if the
minimum amount is not present in the savings account.
In the above use case, there are multiple business rules that help us identify the
•• application logic objects. Applying the thumb rules mentioned in the previous section,
we can identify die following application logic objects:
(1) Account
(2) Savings Account
(3) CurrentAccount
(4) CreditCard
20
I
Each application logic object has corresponding functions for processing business rules. Object Oriented Design
A sample representation of the class diagram is given in Figure 2.3.
Account
- accountNo.: int
- accountHoldersName: String
+ getAccountHoldersName
-
0: String
+ activeAccountO: void
+ closeAccount(): void
.
"
/ <,
SaylngsAccount -ChecklngAccount
1
1
- CredltCard
- carcxo.: int
,- cardHoldersName: String
.
- cardHoldersPANNo: int
- cardHoldersAddress: String
• The utility provided by the object should be used across various layers. '
-
2.5.2 Common Utility Objects
The following are the list of utility objects generally used in a typical enterprise
application:
As we can see, the above utility objects perform specific re-usable and context
independent functions that can be used by a variety of layers and classes. Due to this
context insensitive nature of the utility objects, they are used mostly as static objects and
are used as singletons.
CreditCart
-
.- - cardNo: int
- cardHoldersName: String
- cardHoldersPANNo: int
- cardHoldersAddress: String '\
~
NumberFormatter
In the above example, CreditCard is the application logic object handling the core
business rules. Internally it uses a utility object Numberf'ormatter to convert the user
input into a properly formatted 16 digit credit number. The methods provided in
NumberFormatter such as, formatNumber(String), trimSpaces(String) are generic
functions which act on the input and do nQtdepend on context such as user session.
• Identify nouns: The first step is to look for subjects or nouns in the given
problem domain that has a set of properties. Here, we need to identify
real-world subjects and map them to the static objects. This is often known
as "nounification" and it should represent the proper abstraction of the
real-world objects. For instance, in a bank transaction scenario, we can
easily identify these static objects: Account, Customer, Deposit, etc.
22
I
Similarly, in an e-commerce scenario, we can identify these objects: Item, Object Oriented Desisn
ShoppingCart, Order, Payment, etc. .
" Grouping similar objects: Once we identify the obvious and main static
objects in the first step, we will look closely at the problem domain to see if
there are any other objects that are similar to the identified objects.
Similarity can either be in terms of similar attributes or similar category or
any relationship to the identified objects. These objects can then be added to
the object inventory. For instance, in a banking scenario, a SavingsAccount
and CheckingAccount form the special case for Account and hence then, can
"
be made of sub classes of the Account class.
Duplicate elimination: After these two steps we would need to look for
other Nouns and try to eliminate any duplicate, irrelevant or incomplete
objects. For:'instance, in a problem statement related to the banking scenario,
there could b~ description of the customer's vehicle. Though vehicle would
constitute a separate object, it might not be relevant for the problem domain
at all.
(2) The objects which handle core application logic are called .
2.7 SUMMARY
In this unit, we started by looking at the core object oriented concepts and features of a
class. We the noved on to map real world objects of a problem domain to objects with a
sample use'case. In the next section, we discussed the specification of static objects with
a sample use' case. We then checked the motivating factors and identification of
application logic objects with the help of a few examples. We also saw the criteria for
Utility objects and their identification (with examples). We concluded by checking
commonly used methodology for identification of objects.
23
, ,,
Design and Testing 2;9 FURTHER READINGS
Reference Books
Grady Booch: 'Object-oriented Analysis and Design' ;.Addison-Wesley.
Cox, BJ.; 'Object Oriented 'Programming -An Evolutionary Approach';
Addison-Wesley, Mass.; 1986.
Reference Websites
http://en.wikipedia.org/wikilObject-oriented analysis and design
1) "
24 41
I
UNIT 3 SOFTWARE TESTING TECHNIQUES
. Structure
3.0 Introduction
3.1 Objectives
..
'
3.3 Need for Software Testing
3.9 Summary
3.0 INTRODUCTION
Software testing is a very important phase in software development. It is a repetitive
process that helps identify not only the errors in the developed application but also
corrects those errors. One may think that finding errors is a simple task. Then why would
we need to pay importance to testing. In this unit, we will discuss the different aspects
and importance of testing. Even though testing may seem easy, it is not an easy task and
needs a strategic and systemised approach to ensure suitability.
In this unit, we will begin by defining software testing followed by why there is a
requirement for software testing. .
Further, in this unit, we will discuss two basic categories of testing i.e. Black Box testing
and White Box testing. Any type of test we perform will fall under either of these
categories. During the development of the software, continuous testing is performed at
each level. We will discuss the four levels of testing i.e., unit testing, module testing,
integration testing and s stem testing.
Unit testing is performed to test a single program whereas module testing is required to
test a complete module: The purpose of integration testing is to test that communication
between different modules is error free and the modules are. compatible with each other
. in terms of interfaces and the data that they share. System testing is meant for testing
software in the configuration environment in which it would be made functional. We will
also discuss the basic types of testing that can be performed in system testing such as,
stress testing, recovery testing, security testing and performance testing.
25
I
Design and Testing Finally, when the software is ready to be delivered, it is tested by the end users who will
be the actual users of the application. Under the category of end user testing, we 'would
discuss acceptance testing, alpha testing and beta testing.
3.1 OBJECTIVES
After going through this unit, you should be able to
• explain the meaning of software testing,
," • explain what is the need and requirement for software testing,
• examine the personnel involved in testing,
• write and design test cases for a particular requirement,
•...• explain the concepts of two basic types of testing - black box testing and
... white box testing,
• explain the various levels in software testing i.e. unit testing, module testing,
integration testing, and system testing, I
• explain and design test cases required for unit testing for any requirement,
• explain the importance and requirement of Integration testing,
• explain the approaches to be adopted while conducting integration testing,
• explain the various types of testing, those that are part of system testing such
as, stress testing, security testing, recovery testing, etc.,
• explain the concept and importance of Acceptance testing, and
• explain the concept and importance of Alpha testing and Beta Testing.
Example 1
Suppose we have two requirements as
Req 1: User should be able to copy a source file file 1 into destination file file2.
For this requirement a basic set of test cases would be something like this:
27
Design and Testing
3.6 TYPES OF TESTING
. Depending upon what is tested and who the tester is, there are broadly two types of .
testing:
(i) White Box Testing
(ii) Black Box Testing
3.6.1· White Box Testing
" White Box testing is also known as structural testing or glass box testing. Its goal is to
test the internal code of the software. It tests the program at the level of the.source code.
Here, the tester has the knowledge of the actual source code of the software and what is
tested, is the inner structure of the program. Test cases are written with the knowledge of
the logic of the program. We are only concerned with the testing of accuracy of the logic
of the'program. We do not focus upon the requirements of the software.
We may state that white box testing is the deep and detailed inspection of the logic and
structure of the source code of an application or program. Here, the main focus is to 1
.1•
.. exhaustively execute the program several times, with different inputs to ensure that each
statement of the code is executed and tested .
Example 2
If we have a line of code as below:
If(age >= 18) 0
For testing this code, we must run the program to test three different test cases,
T1: when the value of age is less than 18,.
- T2: when the value of age is equal to 18
T3: when the value of is greater than 18.
And for each test case we must ensure that the right code is executed.
In white box testing, all the test cases are written with the knowledge of the
internal structure and logic of the code to make maximum test coverage of the
code. This is primarily done by the programmer or developer who develops the
code. It is a first step to testing and to ensure that what is implemented in the code
promises to execute accurately." ,
An exhaustive white box testing:
i. Guarantees that all independent paths-have been executed.
ii. Executes all logical decisions on their true and false sides.
Example 3
if - then - else type of decision making code is tested for the true as well as false
value.
If (choice == 1) {
}
else If (choice == 2) {
} -
else If (choice == 3) {
}
In the above case, we must test it for all the cases for the choice value i.e. 1,2,
and3.
28 iii. Executes all loops at their boundary values and within values.
1
Example 4 Software Testing
Techniques
For a loop structure like
for (counter = 0; counter <= 10; counter++) 0
We must test it separately for boundary values of loop variable counter i.e. 0
and 10. We must test for within valueslike 1 to 9:
iv. Executes internal data structure to ensure their validity
Test Case 1:
Test Case 2:
Test Case 3: Check if the user is properly logged in with a valid username
and password
• Test Case 4: Check whether a proper error message is displayed if user
enters an invalid usemame
Test Case 5: Check whether a proper error message is displayed if user
enters an invalid password
29 ,
I
1
Design and Testing If you look carefully, you will realize that, for a single requirement, we have written five
test cases to check all the possible- inputs and expected output. Further, we can write
more detailed test cases to check the requirement as per the guidelines more thoroughly.
On a similar note, test cases are written for all the specified requirements to test the
functionality of the developed software. If you notice, no internal details are used or -
required by the tester: Tester only needs to understand the requirements specified in the
requirement specification document and write all possible test cases for each
requirement.
.. Here, it would be pertinent to mention that, black box testing is usually done by a
separate dedicated team who are experts in writing the test cases and carrying out the
testing. They are not those who were involved in developing the software
• Unit Testing
• Module Testing
• Integration Testing
- .••..
- Unit Testing
Module Testing
Integration Testing
System Testing
Figure 3.1 : Levels of Testing
30
I
In unit testing, the tester is the developer who has written that program. The Developer Software Testing
tests the source code for its accuracy from different perspectives. The Programmer tests Techniques
whether the correctness or accuracy of the source code works, to ensure that it works
properly. Generates the output as it is expected to in all possible cases .
.The main point here is to note that, unit testing is the responsibility of the programmer
who writes the programs. The Programmer is required to test the program keeping in
view of the code implemented. For instance,
• If the for loop is implemented in the logic of the program, the programmer
must test the program for boundary values as well as for some inner values
and ensure that it gives the correct output in all possible cases.
"
• If a program has file handling, then the programmer must include testing
depending on files features such as, different file attributes, end of file cases,
file exist ornot etc.
Example 7.
With respect to Example 5, Requirementl - User should be able to login to the
website:
For this Requirement I , software may have multiple programs or say units such as:
Each of the. above programs is initially treated as an independent unit of the code
and implemented separately. Each program may be developed by the same
programmer or by separate programmes. This is not our concern here. We must
understand that each program given above is considered as a unit and first tested
independently to ensure that the implemented source code is working properly.
Module testing may fall under the category of white box testing as well as black box
testing.
III the first step, the testing is performed by developers responsible for implementing that
module. It could be that a single developer has worked on a complete module or there
could be multiple developers working simultaneously on the same module. All those who
are involved in implementing the module are responsible for testing the working of the
module as a whole. Again, we must understand that developers test the complete module
31
I
Design and Testing more for checking the accuracy of the code. The developer conducts the white bOJ:(
testing of the module. In unit testing, the focus. was only on testing a single program at
once. Here, multiple programs constituting that module are tested as a whole for
complete accuracy. .
Once the developer is 'convinced that the program fulfils the requirements, the module is
delivered to the testing team or say, "the QA team". The module can be given to the QA
team for thorough functionality testing of that module. The QA team again tests the
module from different perspective'. The module is first tested for its basic functionality.
Once the QA team is assured that the module works as it is expected to work and all
.
"
features are fully implemented, it is tested for other parameters such as efficiency, load,
and abnorinal cases. This phase of module testing falls under the black box testing
category.
Example S
y'
With respect to Example 5,
Requirement! - User should be able to login to the website:
Requirement! can be taken as an independent single module - Login module
As stated above, the Login module has three program units
This task is done by developers first, and the module is then handed over
tothe QA team that tests it not only for functionality but for its
performance as well. Performance, in this case, should include the
following:
. "
,
finding errors. Here, no attention is paid to test the interconnection or interfaces between Software Testing
the various modules. Software, as we know, is the integrated collection of all the Techniques
modules. And these modules communicate with each other. In integration testing, our
focus is mainly on testing the interfaces between the modules,
In software, different modules interact with each other. Different modules communicate
with each other using interfaces or data. Usually the output of one module is passed as
input to another module. .
.
"
parameters expected by the called module. We must test for any parameter mismatch on
both sides .
Example a
Refer to Example 5 and Example 8,
In Example 8, we mentioned that for each functionalityzwe will test different
modules. For Example 5, we can have Login module, Catalogue module, Order
module and Payment module.
33
Design and Testing • We can first integrate Login and catalogue module as module M7 and
test both together.
• Similarly, we can integrate order module and payment module and
can test them as a single.module M8.
• In next step module M7 and MS can be integrated and tested together.
; M5! M6
J J
"
Figure 3.2 shows how modules are grouped together step-by-step and tested. This is an
example of incremental testing.
In the next section, we shall discuss an important type of testing that must be performed
during Integration testing. It is known as Regression testing.
Example 10
With respect to Example 5, we can have the following modules
Module! - Login module
Module2 - Catalogue module
Module3 - Order Module
34
I
Module4 - Payment Module Software Testing
Techniques
..
Module5 - Logout module
• Then, a step further, we will add Oder Module to the previous group .
Now, first, we will perform regression testing to test all the test cases
of Module! and Module2 again to ensure that the functionality
" working previously is not changed or affected due to the addition of
Module3.
, Thus, regression testing is done at each step when we integrate a new module or
change any prev~us code .
•..•. :1
To test vario s parts and aspects of the complete system, .system testing comprises of
different types of tests. Each test type has a defined scope and purpose.
In the next few sections, we shall discuss the following types of testing performed as part
of system testing:
• Stress Testing
• Load Testing
• Performance Testing
• Recovery Testing
Stress Testing
Stress testing is performed to test the stability of a system in abnormal conditions
and unotable environments.
It is performed by executing the system in such a manner that the system demands
resources in enormous quantities beyond normal capacity till the breaking point.
Then the results are observed. A stress testing of a software system is performed to
measure its robustness and to identify the breaking point or usage limit of the
system.
The goal of stress testing is to identify how the system behaves in abnormal
conditions. The goal is to make sure that the system does not stop abruptly in case
of heavy demands in terms of resources such as, memory or disk space, etc.
Security Testing
Security testing is crucial for software systems that deals with sensitive data and
information. When a system uses sensitive data and information, it is very
important to perform security testing. Such systems that deals with important data
are usually the target of improper use or say penetration to steal the information.
35
\.
Design and Testing Some of the common examples of such systems could be the Bariking System, the
Stock management systems, systems involving online payment, or systems dealing
with individual personal information or government data. Such systems are always
under the threat of improper use by attackers who would be interested in stealing
information such as passwords, codes, etc., Hence, for such systems, security
testing is crucial'.
Security testing tests the protection mechanism implemented in the system. The
main purpose is to identify (if any) improper penetration of the information from
the system.
'.
,
Security testing is performed by experienced testers usually hired and trained for
this purpose. They are asked to execute the system as a person who wishes to
penetrate the information. They try to retrieve the password, generate system error
t,.." or browse insecure data to find access to the complete system and so on.
:1 .
Recovery Testing
Recovery testing is also termed as failure testing.
During the execution of the system, the system could fail. System failure means
that a system may hang, or it may crash. It may also happen that during normal
execution, network connectivity may be lost, hardware may fail, database may not
respond and so on. There could be different types of system failure due to various
reasons.
A well developed and robust system must be either able to recover from failure by
itself and resume functioning normally or must stop working without causing any
harm (also known as graceful exit of) to the system. In a nutshell, a system should
-
be fault tolerant.
• Close the application with the help of the task manger and check if the
application exits gracefully.
• Restart the computer and verify that data integrity is maintained even
after the abnormal exit of the application.
Similarly, there could be various failure cases depending upon the nature of the
software. The purpose of recovery testing is to identify and test all such cases. And
then to ensure that software recovers itself from any failure.
Performance Testing
The software must meet all the requirements from the functionality point of view.
But, it is equally important that software response time should be within the
acceptable ranges to the end user. Time taken to perform a task by a software is of
utmost concern to the end user.
Specifically, the time taken by a software to do a task is of high importance in case
.
of real time applications. In real time applications, time is the primary factor for
consideration and performance is of highest priority.
36
Performance testing is system testing wherein the. system is tested for its Software Testing
performance mainly in terms of time taken to respond, Though it is of high Techniques
.
,! importance in real time applications, all software undergoes performance testing,
In performance testing, for example, we test the length/duratien of time taken to
login on a server. If a search is performed, the time taken to show results? If more
time is taken in showing the results, the user may not like- to use the application.
Hence, along with the functionality for each task, time performance and memory
usage is also tested.
..
'
To understand these types of testing, we must also have clear understanding about the
nature of the software developed. In general, software may fall in either of these two
categories - project for a specific customer or a product.
Project for a specific customer is developed only for that client. In this case, only those
requirements provided by the customer are implemented. The end user is the one
customer or say client. In this particular case, acceptance testing is performed. t
The product is the software which is developed for general use for various customers. A
product software example could be Microsoft Office, Adobe Photoshop etc. These are
developed for general usage where the customer may vary from an enterprise to a
student. Thetypes of testing performed by end users are - Alpha Testing and Beta
Testing,
In alpha testing, a proposed customer (end user) who is ready to use the software is
identified. End user performs the testing at the developer's site itself. The software is
.
"
used by the end user, while the developer observes the process. The end user uses the
software in its natural way, and the developer focuses on noticing the way the user takes
arid uses the software. Developers focus on noticing the usability problems faced by the
end user as weIl as the errors countered. .
v'
In beta testing, an end user is identified who is ready to perform the testing at his site.
Beta testing is performed at the site of the end user and the developer is not present. The
Software product is treated as "live;' application by the end user and used in its natural
way. Note that the developer is not present at the moment. Hence, in beta testing, the-
environment in which testing is performed is actuaIly the simulation of the environment
where the product will be actually used. The end user tests the software and records all
the errors encountered. The recorded errors and usability problems are conveyed to the
developer. Developers takes their time to understand.the<, errors and make necessary
changes in the software. .
- (2)
(3)
is also known as structural testing or glass box testing.
3.9 SUMMARY
Testing is a very important phase in. the development cycle of software. No software can
be used without proper systemised testing.
Software testing can be defined as a process of executing it (software or program) again
and again with the purpose of finding errors in it. Other than finding the errors in
software, the important task of testing 'is to ensure that requirements specified are
implemented as desired by the software. Software testing also focuses on analysing the
software from its performance point of view. Good software is not only supposed to meet
the requirements but to perform better in terms of time and resource utilisation. If the
software performs a task in time that is not acceptable to the user, then such software is
of no use in practically.
In brief, we may say that Software testing is a process for evaluating the software for its
quality in terms of meeting requirements, accuracy and efficiency.
Generally, in all types of applications developed, the developers and the QA team are ..
responsible for this task. The developer is the person or team that actually develops the
code for the application. Developers test the application keeping in mind the code
•• implemented. The QA team is a team of engineers who are experts in testing and they
test the software from the point of view of functionality and performance,
There are basically two categories of testing - White Box testing and Black Box Testing.
White Box testing is also known as structural testing or glass box testing. Its goal is to
test the internal code of the software. It tests the program at the level of the source code.
Here, the tester has the knowledge of the actual source code of the software and what is
tested is the inner structure of the program. The testing performed by the developer is
38 white box testing.
Black box testing is also known es functional testing. Here, the internal code is not visible Software Testing
to the tester. The purpose of black box testing is to test the application or software from Techniques
its functionality point of view. The tester tests the application without knowing its
implementation details. Here, while testing, we are not concerned with testing the logic
of the program, rather, we are concerned with testing the functionality against the
requirements ..
. Depending upon the nature of the software developed, testing is performed at various
levels - Unit testing, Module testing, Integration testing and System testing.
Unit testing is under the category of white box testing. In unit testing, a single program or
.unit is-tested for its implemented code. It is performed by the developer who has
" developed the program. The developer focuses on testing only one program at a time
from the perspective of the code that was actually written.
Module testing is used for testing a complete module. A module is logically defined as a
group of programs that achieves
v
a complete functional unit. In module testing, we focus
on testing the complete group as a single module to check the functionality provided by
that module. It may be done by the developers. Hence, falls under the white box
category. If module testing is performed by the QA team members, then, it may fall
under black box testing,
Integrationtesting is performed to test and make sure that everything functions correctly
and runs smoothly when all modules are grouped together. Software is the integrated
collection of all the modules. Modules interact with each other by calling each other's
functions using interfaces. A module can use data generated by another module.A
complete application works only when all the modules integrated together work properly.
The purpose of integration testing is to test the interface compatibility between the
various modules in the software.
Regression testing is also performed during integration testing. In regression testing,
whenever, a module is integrated, then, all the previous functionality is tested firstThis
is done to mak ure that the module integrated later has not affected the working
functionality of the software. Every time, we integrate a module, the regression test has
to be performed.
The next and the final level of testing is System testing. Software does not work alone.
Software collaborates with other hardware, database, network etc. to work as a complete
system. In system esting, we test the software in the configuration environment in which
it is supposed to run. Different types of testing is done during system testing- Security
testing, Stress Testing, Performance Testing, and Recovery Testing.
Finally, software must be tested by the actual end user who will be using it. Different
types of end user testing is performed depending on the nature of the software.
If the software is a customized project that is developed fot a particular customer, then
acceptance testing is performed by the end user. In acceptance testing, the end user is
actually the customer for whom software has been developed. Here, the end user (or
customer) tests the software strictly against the requirements. specified by himlher.
He/she tests to find if the developed software is acceptable or not. Once the customer is
satisfied and has done thorough acceptance testing, then only will the software be
delivered to him .
In alpha testing, certain end users are identified and invited to the developer's site. These
end users test the system while the developers observe them. The developers observe and
record the ways software is being used and all the errors that have occurred. The
developer also records the difficulty faced by the end user in using the software.
Accordingly, developers make changes in the software to remove recorded errors and
difficulties. Alpha testing is performed by the end users but in a controlled environment.
In Beta testing, a few real end user sites are identified and the software is deployed there.
In beta testing, the software is tested in a "live" environment in which it will be used
further. The errors are recorded by the users and given to the developer's team.
39
Design and Testing
3'.10 ANSWERS TO CHECK YOUR PROGRESS
Check Your Progress 1
(1) Software Testing t •
Reference Books
Roger S, Pressman, Software Engineering A Practitioner's Approach (McGRAW-HILL),
K:"k Aggarwal, Yogesh Singh, Software Engineering (NEW AGE INTERNATIONAL
PUBLISHERS), -
Reference Websites
http://en,wikipedia,orglwiki/Software testiJ!&.
40 -»,
UNIT 4 DEVELOPMENT AND EXECUTION
OF TEST CASES
Structure
4.0 Introduction
4.1 Objectives
4.2 Debugging
4.2.1 Debugging Challenges
..
'
4.2.2
4.2.3
Debugging Strategies
Scenarios for Applying Debugging Strategies
4.3 Testing Tools and Environments
4.3.1 Testin .Tools
.. 4.3.2 TestingEnvironment
4.4 Types of Test Cases
4.4.1 Types of Testing Approaches
',4.4.2 Types of Testing Methods
4.4.3 Deep ]jive into Development of Test Cases
4.4.4 Test Cases for Unit Testing
4.4.5
4.4.6
Test Cases for Functional Testing
Test Cases for Integration Testing
"-
4:5 Test Plans
4.5.1 Sample Test Plan
4.6 Summary
4.7 Answers to Check Your Progress
.",..
4.8 Further Readings
4.0 INTRODUCTION
This unit will examine the basic principles involved in software testing includingvarious
kinds of testing and the philosophy in the development and execution of various test
cases. Software testing is ,essentially a validation process involved that analyses the
software from various aspects to verify if it satisfies the expected functionality. lEEE
defines software testing as "Software testing is the process of analysing a software item
to detect the differences between existing and required conditions (that is, bugs) and to
evaluate the features of the software item". Testing is an essential part of the software
development lifecyc1e (SDLC) for the following obvious reasons: '
• It detects the defects early and contributes to the increased' quality of the
project. /'
• It identifies hidden erroneous code in-the software such as, failure to handle
exceptions, erroneous handling of various forms of input data and in
boundary conditions, failure to encode/decode the input/output and others.
• It minimises the overall cost of the software product.
• It checks if the system meets the non-functional requirements (NFR) such as
scalability, performance, and availability.
• It analyses the software adherence to the given specifications and overall
correctness.
• Verification: This is the process to ensure that software is coded as per the
given specifications. For instance, banking software should correctly
implement a "Fund transfer" transaction and satisfy all involved business
rules. Here, various formal methods such as structured testing, manual
inspection will be adopted.
• Validation: This process ensures whether the software meets the end-user
.requirements. For example, a validation process would check if the customer
can run the banking software on a mobile device. This would involve
verification of various testing processes and documents.
Principles of Software Testing
IEEE literature identifies the following seven key principles of software testing:
• Testing shows presence of errors.
• Exhaustive testing is not possible.
• Test early and regularly.
• Accumulation of errors.
• Fading effectiveness.
• Testing depends on context.
• False conclusion: no errors equals usable system.
Testing Lifecycle
The following are the high level testing activities involved in testing the lifecycle
of a software project.
42
>
Development and
>1
• Collect existing test artifacts • Analyze various
>l >1
• Develop test scripts which • Check test environment
Execution of Test Cases
• Review test requirements scenarios for required test can be automated and test data
for correctness and cases including unit • Identify the right • Perform OA testing as
;! correleteness
• Interact with stakeholders to
gain application knowledge
testing, functional testing,.
regression testing,
performance testing and
candidates for automation
-. Test scripts can be
developed for un~ testing,
per the plan
• Use available automated
test scripts and manual
• Establish traceability others functional testing, cases
between requirements and • Prepare OA test cases. performance testing, • Document test results,
is · test cases
• Identify the gaps and
• Check test data readiness
• Create/mcdify test data , regression testing, load
testing
and log defects for failed
cases
.
"
'!I: improvement areas
• Create test strategy.
• Check test environment
as required by the test
cases
• Come up with manual
testing steps for activities
which cannot be
• Verification of bug fixes
• Submit test reports and
metrics
availability and access automated. For Instance • Set up automated
I integration testing often continuous testing
I requires step-wise environment
verification cannot be fully
automated
.. 4.1 OBJECTIVES
After going through this unit, you should be able to
• understand various test scenarios,
• learn about different debugging techniques,
• understand different kinds of testing,
• gain knowledge about various kinds of testing tools, environment, and
• derstand devising test cases and plans for various kinds of testing.
4.2 DEBUGGING
Debugging i the act of analysing and locating the root cause of defects/errors identified'
during the testi g phase. This is often a creative process involving root cause analysis
(ReA) and formulating a hypothesis about the probable cause of the defect. The role of
debugging during the testing cycle is shown below along with activities in each step:
4.2.1 Debugging Challenges
Debugging is often a complex process due to the following challenges:
• Triggering condition/variable isolation: Only a few defects triggered
under specific conditions. Identifying the exact variable'or condition would
be complex as there are a large number of variables. For instance, a function
call may fail only 10% of the times. There are a number of variables such as,
total load, network bandwidth available, data set used, timing, etc.
Identifying an exact cause or combination of variables would be a challenge.
• Intermittency factor: Sometimes, the defect only occurs intermittently and
there would not be any deterministic steps to reproduce the issue all the
time. This temporary issue could be happening due to a variety of reasons
such as, intermittent network issues, dependency on,another condition,
hardware failure, etc.
• Hidden under multiple complex steps: Often only a few defects occur
after executing a huge number of steps under certain conditions;
Reproducing and root causing those defects would be challenging.
• Performance and memory issues: Normally performance and memory
leak issues are difficult to debug as it involves multiple layers, systems and
components. Network bandwidth and user load would further add to the
complexity. 43
.Design and Testing
4.2.2 Debugging Strategies
.Effective debugging involves deep knowledge of underlying systems and processes and
creative thinking; it involves careful generation of hypothesis and testing it. Some of the
most commonly used strategies for debugging are listed below:
• Debugging by cause elimination: Th\S strategy is adopted for complex
. issues that involve different layers and components. Here, we systematically
eliminate one layer or component at a time starting with the
layerlcomponent that is has most. For instance, if there is an issue probably
defective with the page performance we start eliminating various
'. components on that page followed by removing all interfacing components.
If a page is integrated with number of data sources, an issue with one of
those data sources may hog the entire page.
p.w• Combination of test data and conditions: This strategy is used when there
are multiple causes for the defect. We try out various permutations and
combinations of the variables/test data and conditions till we identify with
certainly the exact set of variables that can accurately reproduce the issue.
For instance, if a function call with three arguments rises an exception, we
try combinations of three arguments to understand the exact argument that is
causing the issue.
• Memory profiling: This strategy is normally followed for memory related
issues. A profiler tool is used to analyse h~~ memory during program
execution. This would give insights into components consuming more
memory and the ones which are orphan/not garbage-collected. With this
information we can then deduce the cause for memory leak issues. This
technique also involves analysing memory/thread dumps .
• . Step-wise debugging: This is another technique which is often carried out
with the help of Integrated development environment (IDE) tools, In this
technique; we start the program in "debug mode" wherein, we can control
each step of program execution using IDE. We can then "step-in" and
"step-out" each line of code inspecting values of various variables. This
helps us to get the exact method, line and variable value where the defect
has accused/occurs.
• Call tracing: This is a top-down approach wherein, we trace the call from
the top-most component to the root data source. We examine the return
value at each level to isolate the code that is the cause for the issue.
4.2.3 Scenarios for Applying Debugging Strategies
The following table provides scenarios that warrant a specific debugging strategy:
Debugging Strategy Brief Detail Suitable Scenario
Debugging by cause Eliminate various participating • Apply this technique when the defect
elimination layers and components step- occurs in complex multi-layered
wise systems involving numerous
components.
Combination of test Try out combination of test • Use this technique when we know the
data and conditions data and steps that lead to the data set and steps that lead to the
defect defect
Memory profiling Analyse and profile the • Apply this technique when the defect
memory during program is related to memory such as, abrupt
execution program termination, out-of-memory
issues, and memory dump issues.
Step-wise debugging Execute the program one step • Use this technique when we want to.'
at a time to root cause the take the snapshot of variable values at
issue each step and to isolate the exact step
that is causing the issue .
. Call tracing Trace the function call starting • Use this technique when we know the
from the top-most component sequence of.calls that is causing the'
'till the component causing defect I.
error is identified
44
Development and
Check Your Progress 1
Execution of Test Cases
1~ The strategy that is best suited for debugging memory dump issues is
.
, 2. ' : ' debugging strategy is used to check the values of
variables at various points in program execution.
3. Removing one cause at a time is called : debugging
strategy.
.
" 4.3 TESTING TOOLS AND ENVIRONMENTS
This section provides a list of the various testing tools that are widely used for carrying·
out testing activity.
"t>-"
In this section, we will look at various types of testing and test cases that will be designed
for each type of testing.
I
Development and
4.4.2 Types of Testing Methods Execution of Test Cases
.. Given below in a tabular form, are the main types of testing that falls into one of the
above categories of testing. Test cases will be designed for each of these testing types .
Functional
•
•
Done in a SIT environment
The testing involves high-level design of •
--
Quality Analysis
testing functional modules/components to verify its (QA) Team
working as expected by the design
specifications
• Functional
testing team
• Done in a QA environment
System
-" • This involves carrying out the entire testing in a • Quality Analysis
Testing . fully-integrated environment that is very similar (QA) Team
to that of the customer and also testing the
customer requirements
• Integration
testing team
Testing is done to ensure compliance with
I; •
design specifications, legal regulations
• Security team
~...•~
• .Non-functional requirements such as,
scaIability, usability will be tested
-----'1
\
47
. . Design and Testing 4.4.3 Deep Dive into Development of Test Cases
IEEE defines test case as "A set of test inputs, execution conditions, and expected results
developed for a particular objective, such as to exercise a particular program path or to
verify compliance with a specific requirement."
This section, delves deeper into the development of test cases for some of the prominent
testtypes,
4.4.4 Test Cases for Unit Testing
..
' The unit test case should test the expected behaviour of low-level code structures such as,
functions, classes and components. A good unit test case should check the following on a
given code structure:
• Positive flow for expected behaviour
v-'
..•~. • Boundary conditions including null inputs, empty inputs, large data sets,
reserved characters as inputs, multi-language inputs
• Check all the branches of the flow. If the code fragment contains if-else
conditions or loops then the input data should be designed to cover all
branches and looping criteria to ensure the code is fully covered.
The following is a code example for a simple unit testing test case:
Let's consider the following code fragment. The clase.Integerlvlultiplication
<, has a single
method multiply that takes two integers and returns the product of two input values.
//Class for multiplication
class IntegerMultiplication {
long multipljl,{int a, int b) {
- if (a == null
return (a' b);
11 b == null) return null;
The unit test case for the above class is given below which covers all the scenarios
mentioned:
. IIUl')it test case for the TestlntegerMultiplitation class
public class TestlntegerMultiplication {
IlThis test case tests the positive flow with two integers
public void testmultiplLfor_normaUlowO {
IntegerMultiplication intmul = new IntegerMultiplicationO;
assertTrue(intmul.multiply(50, 40) == 200);
assertTrue(intmul.multiply(20, 10) == 200);
IlThis test case tests the method for various boundary conditions
}
}
Usually functional test cases are based on the use cases that they are tested for:
·1. Various d.a!~jnputs
r'-
2. Exception/boundary scenarios
I
49
;.
Design and Testing 4.4.6 Test Cases for Integration Testing
Integration testing will be done to test the following key aspects of integration:
(1) Handling of data flow across interfaces
(2) Handling of exception scenarios and boundary conditions across interfaces
(3) Performance of upstream systems
(4) Check sub-systems
(5) Error handling (time outs, network outage, transaction rollback) across
interfaces.
A typical integration test case consists of the following steps:
, (1) Perform setup. This step includes establishing connection with the interface
and initialising all necessary variables .
.v. (2) Populate dummy data.
(3) Test scenarios.
Illntegration test case for a DBConnection object
public class testDBConnectiqn {
Connection con;
Context ctx;
-
populateDummyTableDataO;
50
Development and
• It should cover all kinds of testing including unit, functional, integration and
Execution of Test Cases
regression testing that will be carried out ill the project.
• Testing approach: agile or traditional approach, manual or automated
approach.
• Should contain specifications of test units, key features that needs to be
tested and the expected outcome. .:
• It should contain the list of test deliverables.
Sample Test Plan
., A sample template for the test plan containing the "table of content" items is.given
below:
Sample Test Plan: Test Plan ABC Project
TABLE OF CONTENTS
'.
1. Introductio;'
2. Objectives
3. Reference Documents
3.1. Project Plan
3.2. Requirements specifications
3.3. High level design
3.4. Low level design document
3.5. Enterprise standard guidelines
4. Scope
5. Testing Strategy
5.1. Unit Testing
5.2. System and Integration Testing
5.3. Integration testing
5.4. Service testing
5.5. Performance and Stress Testing
·,6. User Acceptance Testing
5~. Regression Testing
6. Hardware Requirements
7. Test Schedule
8. Features to Be Tested
9. Features Not to Be Tested
10. Roles & Responsibilities
11. Schedules
12. Dependencies
13. Risks and Assumptions
14. Test phase entry and exit criteria
15. Test Deliverables
15.1. Test estimates
15.2. Test schedules
15.3. Test specification
15.4. Test script
15.5. Test data
15.6. Test reports
16. Tools
17. Approvals 51
I
Design and Testing
4.6 SUMMARY
In this unit, we started by laying out the key design principles and looked at various
stages of a testing life cycle. We then examined various challenges in debugging a defect
discovered during testing and commonly employed' strategies to debug the defect. We
looked further at various testing tools that are used in testing and different testing
environment. We also discussed different kinds of testing and designing test cases for
some of the prominent ones. We finally examined at the sample test plan with various
" sections.
Engineering.
52
I
MPDD-IGNOU/P.O. 2.0 KlSep. 2018 (Reprint)
ISBN: 978-81-266-6611-9