Unit 3 Software Design and Testing - Part1
Unit 3 Software Design and Testing - Part1
Customer Developers
(Implementers)
The design needs to be
Correct & complete
Understandable
At the right level
Maintainable
Initial requirements
Completed design
How will the reports and screens look Network Architecture and any other
like? thing that translates the requirements
in to a solution to the customer’s
problem
Modularity in Software Design
• Modularity is the single attribute of software that
allows a program to be intellectually manageable.
• It enhances design clarity, which in turn eases
implementation, debugging, testing, documenting,
and maintenance of software product.
• Examples of Modules: Fortran subroutine; Ada
package; Procedures & functions of PASCAL & C;
C++ / Java classes ; Java packages
Advantage of Modular Design
i. Well defined subsystem
ii. Well defined purpose
iii. Can be separately compiled and stored in a library.
iv. Module can use other modules
v. Module should be easier to use than to build
vi. Simpler from outside than from the inside.
Two important terms
• Module Coupling: Coupling is the measure of the
degree of interdependence between modules.
12
• Data Coupling: The dependency between module A and B is said to be data
coupled if their dependency is based on the fact they communicate by only
passing of data. Other than communicating through data, the two modules are
independent.
• Stamp Coupling: Stamp coupling occurs between module A and B when
complete data structure is passed from one module to another.
• Control Coupling: Module A and B are said to be control coupled if they
communicate by passing of control information. This is usually accomplished by
means of flags that are set by one module and reacted upon by the dependent
module.
• Common Coupling: With common coupling, module A and module B have
shared data. Global data areas are commonly found in programming languages.
Making a change to the common data means tracing back to all the modules
which access that data to evaluate the effect of changes.
Module Cohesion
• Cohesion is a measure of the degree to which the
elements of a module are functionally related.
Module strength
Decomposition Partition of the system into design Identification, type purpose, Hierarchical decomposition
description entities function, subordinate diagram, natural language
Dependency Description of relationships among Identification, type, purpose, Structure chart, data flow
description entities of system resources dependencies, resources diagrams, transaction diagrams
Interface List of everything a designer, Identification, function, Interface files, parameter tables
description developer, tester needs to know to interfaces
use design entities that make up the
system
Detail description Description of the internal design Identification, processing, data Flow charts, PDL etc.
details of an entity
28
Object Oriented Design
Object Oriented Design begins with an examination of the
real world “things” that are part of the problem to be
solved. These things (which we will call objects) are
characterized individually in terms of their attributes and
Object Oriented Design is not dependent on any
behavior.
specific implementation language. Problems are
modeled using objects. Objects have:
• Behavior (they do things)
• State (which changes when they do things)
29
Concepts of Object Oriented Design
• Objects
• Classes
• Messages
• Abstraction
• Encapsulation
• Polymorphism
• Hierarchy
• Attributes
Steps for analysis & design of object oriented system
Activity Diagram State –Chart Diagram
Sequence Diagram
33
Software Testing
• What is Testing?
Many people understand many definitions of testing :
39
Software Testing
Alpha, Beta and Acceptance Testing
The term Acceptance Testing is used when the software is developed for a specific
customer. A series of tests are conducted to enable the customer to validate all
requirements. These tests are conducted by the end user / customer and may
range from adhoc tests to well planned systematic series of tests.
The terms alpha and beta testing are used when the software is developed as a
product for anonymous customers.
Alpha Tests are conducted at the developer’s site by some potential customers.
These tests are conducted in a controlled environment. Alpha testing may be
started when formal testing process is near completion.
Beta Tests are conducted by the customers / end users at their sites. Unlike alpha
testing, developer is not present here. Beta testing is conducted in a real
environment that cannot be controlled by the developer. 40
Software Testing
Functional Testing
Input Output
domain domain
41
Software Testing
Boundary Value Analysis
Consider a program with two input variables x and y. These input variables have
specified boundaries as: a≤x≤b
c≤y≤d
Input domain
d
y
c
a b
x
Fig.: Input domain for program having two input variables 42
Software Testing
The boundary value analysis test cases for our program with two inputs variables
(x and y) that may have any value from 100 to 300 are: (200,100), (200,101),
(200,200), (200,299), (200,300), (100,200), (101,200), (299,200) and (300,200). This input
domain is shown in Fig. 8.5. Each dot represent a test case and inner rectangle is the
domain of legitimate inputs. Thus, for a program of n variables, boundary value analysis
yield 4n + 1 test cases. Input domain
400
300
y 200
100
1 0 50 50 Not Quadratic
2 1 50 50 Real Roots
3 50 50 50 Imaginary Roots
4 99 50 50 Imaginary Roots
5 100 50 50 Imaginary Roots
6 50 0 50 Imaginary Roots
7 50 1 50 Imaginary Roots
8 50 99 50 Imaginary Roots
9 50 100 50 Equal Roots
10 50 50 0 Real Roots
11 50 50 1 Real Roots
12 50 50 99 Imaginary Roots
13 50 50 100 Imaginary Roots
44
Software Testing
Robustness testing
It is nothing but the extension of boundary value analysis. Here, we would like to
see, what happens when the extreme values are exceeded with a value slightly
greater than the maximum, and a value slightly less than minimum. It means, we
want to go outside the legitimate boundary of input domain. This extended form
of boundary value analysis is called robustness testing and shown in Fig. 6
There are four additional test cases which are outside the legitimate input
domain. Hence total test cases in robustness testing are 6n+1, where n is the
number of input variables. So, 13 test cases are:
47
Software Testing
Equivalence Class Testing
In this method, input domain of a program is partitioned into a finite number of
equivalence classes such that one can reasonably assume, but not be absolutely sure,
that the test of a representative value of each class is equivalent to a test of any other
value.
1.TwoThe
steps are requiredclasses
equivalence to implementing this method:
are identified by taking each input condition and
partitioning it into valid and invalid classes. For example, if an input condition
specifies a range of values from 1 to 999, we identify one valid equivalence
class [1<item<999]; and two invalid equivalence classes [item<1] and
2. [item>999].
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
48
that no two invalid classes mask each other.
Invalid input
51
Software Testing
Structural Testing
A complementary approach to functional testing is called structural / white box testing. It
permits us to examine the internal structure of the program.
Path Testing
Path testing is the name given to a group of test techniques based on judiciously selecting a
set of test paths through the program. If the set of paths is properly chosen, then it means
that we have achieved some measure of test thoroughness.
This type of testing involves:
1. generating a set of paths that will cover every branch in the program.
2. finding a set of test cases that will execute every path in the set of program
paths.
52
Software Testing
Flow Graph
The control flow of a program can be analysed using a graphical representation known as
flow graph. The flow graph is a directed graph in which nodes are either entire statements
or fragments of a statement, and edges represents flow of control.
55
Calculate Cyclomatic complexity of the following Graph:
= 13-13+2*3
=6
This method with P 1 can be used to calculate the complexity of a collection of
programs, particularly a hierarchical nest of subroutines.
57
Software Testing
Two alternate methods are available for the complexity calculations.
1. Cyclomatic complexity V(G) of a flow graph G is equal to the number of
predicate (decision) nodes plus one.
V(G)= +1
Where is the number of predicate nodes contained in the flow graph
G.
2. Cyclomatic complexity is equal to the number of regions of the flow
graph.
58
Software Testing
Solution
Cyclomatic complexity can be calculated by any of the three methods.
1. V(G) = e – n + 2P
= 13 – 10 + 2 = 5
2. V(G) =π+1
=4+1=5
3. V(G) = number of regions
=5
Therefore, complexity value of a flow graph in Fig. is 5.
59
Software Testing
Graph Matrices
A graph matrix is a square matrix with one row and one column for every node in the graph.
The size of the matrix (i.e., the number of rows and columns) is equal to the number of
nodes in the flow graph. Some examples of graphs and associated matrices are shown in fig.
62
Software Testing
Unit Testing
There are number of reasons in support of unit testing than testing the entire
product.
1. The size of a single module is small enough that we can locate an error
fairly easily.
2. The module is small enough that we can attempt to test it in some
demonstrably exhaustive fashion.
3. Confusing interactions of multiple errors in widely different parts of the
software are eliminated.
63
Software Testing
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? One approach is to construct an
appropriate driver routine to call if and, simple stubs to be called by it, and to insert
output statements in it.
✔ Stubs serve to replace modules that are subordinate to (called by) the module to
be tested. A stub or dummy subprogram uses the subordinate module’s interface,
may do minimal data manipulation, prints verification of entry, and returns.
This overhead code, called scaffolding represents effort that is import to testing, but
does not appear in the delivered product.
64
Software Testing
66
Software Testing
Compatible Will the product work correctly in conjunction with existing data,
software, and procedures?
Dependable Do adequate safeguards against failure and methods for recovery exist in
the product?
Documented Are manuals complete, correct, and understandable?
70
Software Maintenance
Regression Testing
Regression testing is the process of retesting the modified parts of the software
and ensuring that no new errors have been introduced into previously test code.
“Regression testing tests both the modified code and other parts of the program
that may be affected by the program change. It serves many purposes :
1.
We create test suites and test plans We can make use of existing test suite and
test plans
2.
We test all software components We retest affected components that have
been modified by modifications.
3.
Budget gives time for testing Budget often does not give time for
regression testing.
4.
We perform testing just once on a We perform regression testing many times
software product over the life of the software product.
5.
Performed under the pressure of Performed in crisis situations, under greater
release date of the software time constraints.
72
Software Maintenance
▪ Regression Test Selection
Regression testing is very expensive activity and consumes significant amount of
effort / cost. Many techniques are available to reduce this effort/ cost.
4. The symptom may be caused by a human error that is not easily traced.
79
Software Testing
81
Software Testing
82
Software Testing
Testing Tools
One way to improve the quality & quantity of testing is to make the process as
pleasant as possible for the tester. This means that tools should be as concise,
powerful & natural as possible.
The two broad categories of software testing tools are :
Static
Dynamic
83
Software Testing
There are different types of tools available and some are listed below:
84
Software Testing
6. Test file/ data generators, used to set up test inputs.
85