State based testing is used as one of the most useful object oriented software testing techniques. It uses the concept of
state machines. State machines are used to model the behavior of objects. It represents various states which an object is
expected to visit during its lifetime in response to events or methods.
During state based testing, the unit testers typically perform the following steps:
Create a state transition diagram for each relevant class with logical states. Transform the state transition diagrams
into a transition trees, whereby die root of the tree is the start state, and each branch is made up of a series of
transitions between states that terminates when a transition returns the object under test to a previous state. Create a
state*based test suite for the class under test, whereby each test case corresponds to a branch of the transition tree.
Each test case starts by instantiating an object under test in the start state: The test case then sends the object under
test a series of test stimuli (either messages with appropriate parameters or exceptions with appropriate attributes that
are intended to walk the object under test down the corresponding branch of the transition tree. The test oracle is the
state transition diagram. Each test case compares each actual post*stimuli state of the object under test with the state
that is predicted by the branch of the transition tree that generated the test case. In object*oriented testing literature,
a class is considered to be a basic unit of test mu A major characteristic of classes is the interaction between data
members and member functions. This interaction is represented as definitions and uses of data members in member
functions and can be properly modeled with state chart diagrams. The data members represent the allowable slates of
an object and member functions represent the change of states i.e. transitions. Therefore, specifications of classes can
be done in a better way using slate diagrams. Object*oriented technologies can reduce or eliminate some problems
typical of procedural software, but may introduce new problems that can result in classes of faults hardly addressable
with traditional testing techniques. In particular, state* dependent faults tend to occur more frequently in
object*oriented software than in procedural software; almost all objects have an associated state, and the behavior of
methods invoked on an object depends in general on the object's state. Such faults can be very difficult to reveal
because they cause failures only when the objects are exercised in particular states. So, state based testing provides a
better approach of testing.
(a) What are metrics? Why so we need to measure software?
The metrics can be defined as the continuous application of measurement based techniques to the software
development process and its products to supply meaningful and timely management information, together with the use
of those techniques to improve that process and its products.
Need to measure software
The software industry * as all other industry * has as its main goals to deliver products and services to the market. This
must be done at a price that the customer accepts as reasonable and at a quality that the customer wants. One of the
main characteristics of the market is that it changes, not by itself but through the competition among those who provide
the goods that is sold. The changes will not happen at the same time for all industries, but only when the players can no
longer expand in any other way. The main results of this competition are lower prices and higher quality * not because
the
producers want it to be this way, but because it is the only way in which they can survive.
The software industry, like any other industry, can improve only in one way; by understanding the product and the
process that produces it. Thus, we can define the first goal of software measurement.
We need measurement in software development to improve the development process so that we can increase product
quality and thus increase customer satisfaction
In addition to this long*term need, we also need measurement in order to agree on the quality of a delivered product.
The lime when the customer in awe watched the blinking lights is gone forever. The customers now want quality and as
a result of this we need to be able to establish a common ground for specifying, developing and accepting a software
product with an agreed quality. Even though we accept the ISO definition of quality as the products degree of satisfying
the customers needs and expectations, we need something more concrete when we start to write a contract and
develop a software system. The definition given in the standard ISO 9126 is a good starting point even though it
concentrates on the product and leaves out important factors such as price, time of delivery and quality of service. Thus,
our second need is
(b) Discuss some methods of integration testing with examples.
The various approaches of integration testing are:
Top down integration
Top*down integration testing is an incremental approach to construction of program structure. Modules are integrated
by moving downward through the control hierarchy, beginning with the main control module (main program). Modules
subordinate (and ultimately subordinate) to the main control module are incorporated into the structure in either a
depth*first or breadth*first manner. Consider the following example:
*Depth*first integration would integrate all components on a major control path of the structure. Selection of a major
path is somewhat arbitrary and depends on application* specific characteristics. For example, selecting the left hand
path, components Ml, M2 , MS would be integrated first. Next, M8 or (if necessary for proper functioning of M2) M6
would be integrated. Then, the central and right hand control paths are built.
* Breadth*first integration incorporates all components directly subordinate at each level, moving across the structure
horizontally. From the figure, components M2, M3, and M4 (a replacement for stub S4) would be integrated first. The
next control level, MS, M6, and so on, follows.
Bottom up integration
Bottom*up integration testing, as its name implies, begins construction and testing with atomic modules
(i.e.components at the lowest levels in the program structure). Because components are integrated from the bottom up,
processing required for components subordinate to a given level is always available and the need for stubs is eliminated.
Consider the following example:
Integration follows the pattern illustrated in Figure. Components are combined to form clusters 1, 2, and 3. Each of the
clusters is tested using a driver (shown as a dashed block). Components in clusters 1 and 2 are subordinate to Ma.
Drivers D1 and D2 are removed and the clusters are interfaced directly to Ma. Similarly, driver D3 for cluster 3 is
removed prior to integration with module Mb. Both Ma and Mb will ultin ately be integrated with component Me, and
so forth.
We need measurement on software so that we can understand and agree on product quality
(E)What are the major problems that we face during object oriented testing?
1.White-box testing methods can be applied for testing the code used to implement class operations, but not
up to much extent
(a) Explain how object oriented testing is different from procedural testing? Explain with example.
Ans: Procedure testing shall model the procedural requirements of the software system as a complete and delivered
unit. Procedure Requirements shall define what is expected of any procedural documentation and shall the written in
the form of Procedural instructions. These procedural instructions will normally come in the form of one of the following
documents:
A user Guide
An Instruction Manual
A User Reference Manual
This information will normally define how the user is meant to:
Set up the system for normal usage
Operate the system in normal conditions
Become a competent user of the system (tutorial files)
Trouble*shoot the system when faults arise
Re*configure the system
Procedural testing shall be measured in the following ways:
Static testing * shall be measured as the percentage of the total specified procedural requirements, which have been
covered by procedural instructions., reviewed.
Dynamic testing as a percentage of the specified procedural requirements which have been executed.
Object*Oriented testing is much more similar to the way the real world works; it is analogous to the human brain. Each
program is made up of many entities called objects. Objects become the fundamental upi ts and have*behavior, or a
specific purpose, associated with them. Objects cannot directly access another object's data. Instead, a message must be
sent requesting the data, just like people must ask one another for information; we cannot see inside each other's
heads. Object Oriented testing include testing techniques like Analysis and Design testing, class tests, Integration : tests,
validation test, and system tests. Benefits of Object*Oriented programming which make it different from procedural
programming are as follows:
ability to simulate real*world event much more effectively code is reusable thus less code may have to be written
data becomes active better able to create GUI (graphical user interface) applications programmers are able to reach
their goals faster
Programmers are able to produce faster, more accurate and better*written applications (in the case of a veteran
programmer, by a factor of as much as 20 times compared with a procedural program).
Levels of Testing
Unit testing
Integration testing
System testing
Unit testing
Reasons to support unit testing
* Easy to locate the bug * Exhaustive testing upto some extent * Interaction of multiple errors can be avoid
Requires overhead code for driver and stub called as
Scaffolding Generate scaffolding automatically by means of test harness Requires detailed knowledge of the internal
program design, thus,
* Unit testing is typically carried out by programmers.
The tests performed can be behavioral or structural.
A sample Executable test program:
*Works on a table in the test database *Typical structure:
*Input
*Expected_Result
*Actual_Result
(b) Explain function oriented metrics and compare with size oriented metrics with examples.
Ans: Metrics are the technical process that is used to develop a product. The process is measured to improve it and the
product is measured to increase quality. Measurements can be either direct or indirect. Direct measures are taken from
a feature of an item (e.g. length). Direct measures in a product include lines of code (LOC), execution speed, memory
size, and defects reported. Indirect measures associate a measure to a feature of the object being measured (e g quality
is based upon counting rejects). Indirect measures include functionality, quality, complexity, efficiency, reliability, and
maintainability. Direct measures are generally easier to collect than indirect measures. They are divided into:
Size*oriented metrics are used to collect direct measures of software engineering output and quality.
Function*oriented metrics provide indirect measures.
Size*oriented metrics are a direct measure of software and the development process.
These metrics can include:
effort (time)
money spent
KLOC (1000s lines of code)
pages of documentation created
errors
people on the project
From this data some simple size*oriented metrics can be generated.
Productivity = KLOC / person*month
Quality = defects / KLOC
Cost = Cost / KLOC
Documentation=pages of documentation /LOC
Function*Oriented Metrics: Function*oriented metrics are indirect measures of software which focus on functionality
and utility. The first function*oriented metric was proposed by Albrecht (IBM, 1979} who suggested a productivity
measurement approach called the function point method. Function points are derived from countable measures and
assessments of software complexity. An unadjusted function point count or UFC is calculated based on five
characteristics.
The Five Characteristics:
1.number of user inputs 2.number of user outputs
3.number of user inquiries (on*line inputs) 4.number of Files 5.number of external interfaces (tape, disk)
(b)Writc a C program for calculation of roots of a quadratic equation. Find out its all software science metrices.
Ans: /* program to find the root of a quadratic equation */
#include<stdio.h>
#include<conio.h>
#include<math .h>
int main()
{
int a,b,c;
float r1,r2,up;
printf("Enter value of a : );
scanf(%d, &a);
printf("Enter value of b : ");
scanf("%d", &b);
printf("Enter value of c:);
scanf(%d", &c);
up=(b*b)*(4*a*c);
if(upM)
{
printf("\n ROOTS ARE REAL ROOTS\n);
r1 = ((*b) + sqrt(up)) /(2*a);
r2 = ((*b)*sqrt(up))/(2*a);
Integration Testing is a level of the software testing process where individual units are combined and tested as a group.
The purpose of this level of testing is to expose faults in the interaction between integrated units.
Test drivers and test stubs are used to assist in Integration Testing.
Note: The definition of a unit is debatable and it could mean any of the following:
1.the smallest testable part of a software
2.a module which could consist of many of 1
3.a component which could consist of many of 2
During the process of manufacturing a ballpoint pen, the cap, the body, the tail and clip, the ink cartridge and the
ballpoint are produced separately and unit tested separately. When two or more units are ready, they are assembled
and Integration Testing is performed. For example, whether the cap fits into the body or not.
Integration Testing Techniques
Decomposition*Based Integration
Decomposition based on packaging partitions
Packaging basis is the functional decomposition tree
Based on interfaces i.e. inputs & outputs
Big Bang Approach
All the units are compiled together and tested at once. pg
works well for small systems with well defined components and interfaces.
Drawbacks: Difficult to isolate the defects. Very difficult to make sure that all the cases for integration Testing are
covered testing are covered.
Top*Down Integration Testing: Top Down Integration as the term suggests, starts always at the top of the program
hierarchy and travels towards its branches. This can be done in either depth*first or breadth*first.
Bottom*Up Integration Testing: Bottom Up integration as it name implies starts at the lowest level in the program
structure.
Sandwich/Hybrid is an approach to Integration Testing which is a combination of Top Down and Bottom Up approaches.
Call Graph*Based Integration
Call Graph*based integration is based upon messages (function calls) and not on the decomposition tree.
represented pictorially through a directed graph termed call graph. moves in the direction of structural testing.
System Testing
Testing conducted on the complete integrated
system. Done after Unit, Component and Integration testing. Evaluates system compliance with requirements.
Brings out defects that are not directly attributable to a module / interface * are not directly attributable to a module
/ interface. But are based on issues that are related to design and architecture of the whole product. According to
Petschenik guidelines for choosing test cases during system testing *Testing the system capabilities is more important
than testing components *Testing the usual is more important than testing the Exotic *In case of modifications; test old
capabilities rather than new ones Attributes evaluate during system testing * Usable * Secure * Compatible *
Dependable *documented
Public access to data members (PAD) - This metric shows the number of classes that access other class's attributes and
thus violation of encapsulation
Inheritance
Number of root classes (NOR) - A count of distinct class hierarchies.
Fan in (FIN) - FIN > 1 is an indication of multiple inheritance and should be avoided.
Number of children (NOC) and depth of the inheritance tree (DIT) - For each subclass, its superclass has to be re-tested.
The above metrics (and others) are different than those used in traditional software testing, however, metrics collected
from testing should be the same (i.e. number and type of errors, performance metrics, etc.).
What is Path Testing?
Path Testing is a structural testing method based on the source code or algorithm and NOT based on the specifications.
It can be applied at different levels of granularity.
Path Testing Assumptions:
The Specifications are Accurate The Data is defined and accessed properly There are no defects that exist in the
system other than those that affect control flow
Path Testing Techniques:
Control Flow Graph (CFG) - The Program is converted into Flow graphs by representing the code into nodes, regions
and edges. Decision to Decision path (D-D) - The CFG can be broken into various Decision to Decision paths and then
collapsed into individual nodes. Independent (basis) paths - Independent path is a path through a DD-path graph which
cannot be reproduced from other paths by other methods.