Software Testing
Lecture 5
General Levels of Testing
Chapter 3: Testing in Software Life Cycle
Agenda for today
Levels of Testing
Component Testing
Stub’s and Drivers
Unit Testing
Points for Unit Testing
Tools for Unit Testing
Integration Testing
Integration Testing Approaches
Bottom Up and Top Down integration Testing
BigBang and Adhoc integration Testing
General Levels of Testing
Component Testing
•Testing of separate software component is known as component testing
•Objective of component testing is to verify the input/output behavior of
the test object
•A group of components is known as module testing.
•The main characteristic is that the software components are tested
individually and isolated from all other software components of the
system.
•The isolation is necessary to prevent external influences on components.
• Most often stubs and drivers are used to replace the missing software and
simulate the interface between the software components
Test Objects, Stubs and Driver
• Test objects are program modules/units or classes, (database) scripts, and
other software components.
•Drivers are the dummy programs which are used to call the functions of the
lowest module in case the calling function does not exist.
OR
A driver calls the component to be tested.
• Stubs can be referred to as code a snippet which accepts the
inputs/requests from the top module and returns the results/ response.
OR
-> A stub is called from the software component to be tested.
Component Testing Objectives
• Reducing risk
• Verifying whether functional and non-functional behaviours of the
component are as expected
• Building confidence in the component’s quality
• Building confidence in the component’s quality
• Finding defects in the component
• Preventing defects from escaping to higher test levels
Component Testing: Example
•Scenario: There are two web pages. In one of the web pages there are a
many certain fields like username, address, mobile no. etc in which data
has to be entered. In the other (second) web page also there are certain
fields which carry forward the data from the first page. Testing the
functionality of these individual pages is called Component Testing.
•Components are tested as soon as they are created,
• There can be results retrieved from a component under test, are
dependent on other components which in turn are not developed
•So in order to test that component, we use Stubs and Drivers
Stubs and Driver’s Difference
Stub Driver
Type Dummy codes Dummy codes
A piece of code that emulates the A piece of code that emulates a calling
Description
called function. function.
Used in Top Down Integration Bottom Up Integration
To allow testing of the upper levels of To allow testing of the lower levels of
Purpose the code, when the lower levels of the the code, when the upper levels of the
code are not yet developed. code are not yet developed.
Stub and Driver Example 1:
• Suppose Function A that calculates the total marks obtained by a student
in a particular academic year.
• Suppose this function derives its values from another function (Function b)
which calculates the marks obtained in a particular subject.
Example 2
• We have 3 modules login, home, and user module in website.
• Login module is ready and need to test it, but we call functions from home
and user (which is not ready)
• What we will do?
• Stub
• For the same example if we have Home and User modules get ready and
Login module is not ready.
• Driver
Unit Testing
• Check individual parts functionality
• Aim is to isolate each unit of the system to identify, analyze and fix the
defects
• Done by developers
• Reduces cost of testing
• Developers can also re-use code
• Facilitates changes
• Example: Testing a function: whether the loop or program is working
properly or not
Unit Testing Example
Almost every web application requires its users/customers to log in. For
that, every application has to have a “Login” page which has these
elements:
- Account/Username
- Password
- Login/Sign in Button
- For unit testing what which test cases will be needed?
Points for Unit Testing
• Functional :
- Does code functionally perform the task?
• Boundaries :
- What are the minimum, maximum values for the function?
• Termination:
- What happens in the normal termination and abnormal termination?
• Outputs:
- What are the expected outputs of the function?
• Inputs:
- What are the expected inputs to the function?
• Interaction:
- What other modules/functions does this interact with?
Unit Testing Tools
• Junit
• Nunit
• JMocKit
• EMMA
• PHPUnit
Integration Testing
• Integration testing is carried out when integrating (i.e., combining):
◦ Units or modules to form a component
◦ Components to form a product
◦ Products to form a system
• Multiple modules & these are developed by different developers.
• Find interface defects between the modules/functions
• Checks connectivity or data transfers
• Developer’s or tester’s performs this type of testing.
• Example: Battery and sim card are integrated i.e. assembled in order to start the
mobile phone.
• e.g Computer and keyboard
Integration Testing Example
•Online shopping website
• One developer was assigned to develop each of the modules below.
User registration and Authentication/Login
Product Catalogue
Shopping Cart
Billing
Payment gateway integration
Shipping and Package Tracking
• The QA Manager suggested that integration testing should be performed.
• Which types of bugs found during integration Testing?
Integration Testing Approaches
Mainly four approaches:
• Top Down approach
• Bottom up approach
• BigBang approach
• Adhoc approach
Top-down Integration Testing
• Testing the top-most modules
• Gradually moving down to the lowest set of modules one-by-one
• Stubs used when lower modules are not ready
• Critical Modules are tested on priority
Bottom up Integration Testing
• Starts with testing the lowest units of the application
• Gradually moving up one-by-one.
• Drivers will be used to simulate the functionality of the missing
modules
• Development and testing can be done together
Big Bang Integration Testing
• All components tested atleast once
• Individual modules of the programs are not integrated until every thing
is ready.
• Convenient for small systems
• Saves time
Ad hoc Integration Testing
• Testing performed without proper planning and documentation
• The components are being integrated in the (casual) order in which
they are finished.
• Saves time because every component is integrated as early as possible
into its environment.
• Used for limited time to do exhaustive testing
Thank you