Software Testing
Software Testing
Controllability: “ The better we can control the software, the more the
testing can be automated and optimize”
All possible output can be generated through some combination of
input
All code is executable through some combination of input
Software Testability continued…..
Software and hardware state and variables can be controlled directly by
the test engineer
Input and output format are consistent and structured
Tests can be conveniently specified, automated and reproduce.
Simplicity: “The less there is to test, the more quickly we can test it”
Functional simplicity (minimum requirement)
Structural simplicity (architecture is modularized to limit propagation of
fault)
Code Simplicity (a coding standard is adopted for ease of inspection and
maintenance)
Software Testability continued…..
Stability: “ The fewer the changes ,the Fewer the disruption to testing”
Changes to software are infrequent
Changes to software are controlled
Change to software do not invalidate existing tests
The software recovers well from failures
While until
Sequence
If Statement
Case
Flow Graph Notation and Cyclomatic
Complexity
33
6 4
4
7 88
5
9
10
11
Flow Graph Notation and Cyclomatic
Complexity
2,3
6 4,5 node
R2
7 R3 8 R1
9
10
Edges R4
11
Flow Graph Notation and Cyclomatic
Complexity
Cyclomatic complexity is software metrics that provide a quantitative
measure of the logical complexity of program
When used in the context of the basis path method ,the value computed
defines the number of independent path in basis set of the program and
provides us with an upper bound for the number of test that must be
conducted to ensure that all statement have been executed at least
once
An independent path is any path through the program that introduce at
least one new set of processing statement or new condition
For previous flow graph following are different independent path
Path1 : 1—11
Path2: 1—2—3— 4 – 5 – 10 – 1 – 11
Path3 : 1 – 2 – 3 – 6 – 8 – 9 – 10 – 1 – 11
Path 4: 1 – 2 – 3 – 6 – 7 – 9 – 10 – 1 – 11
Each path introduce a new edge
Flow Graph Notation and Cyclomatic
How do we know Complexity
how many paths to look for?. The
computation of cyclomatic complexity provide the answer
Complexity is computed in any one of following ways
Condition Testing
Condition testing is a test case design method that exercise the logical
condition contained in program module
A simple condition is a Boolean variable or a relational expression ,possibly
preceded with not operator. A relational operator may takes the form
E1 <relational-operator> E2
E1 and E2 are arithmetic Expression and <relational operator > is on of
following :<, <=,>,>=,=, !=
A compound statement is composed of two or more simple conditions, Boolean
operator and parenthesis
A condition without relation expression is referred to as Boolean Expression
Condition Testing Continued……
If a condition is incorrect, then at least one component of the condition is
incorrect. Therefore types of errors in condition include following
Undirected link
Parallel link
Object#3
Allows editing of
Is Represented as
Contains
Document
Text
Graph-Based Testing Methods continued…..
Bezier describe number of behavioral testing methods that can make
use of graphs
Data flow Modeling: The nodes are data objects and link are their
transformation that occur to translate one data object to other
Timing model: The nodes are program objects and link are sequential
connection between those objects
All objects are tested for transitive, symmetric and reflexive properties
Equivalence Partitioning
It is black box testing method that divides the input domain of
program into classes of data from which test case can be
designed
It strive to define a test case that uncover classes of errors
thereby reducing the number of test case that must be developed
Test case designed is based on evaluation of equivalence classes
from an input condition
An Equivalence class represent a set of valid or invalid state for
input condition
They are defined according to following guidelines
1) If input condition specifies a range one valid and two invalid
equivalence classes are defined
2) If an input condition require a specific value one valid and two
invalid classes are defined
3) If input specifies a set then one valid and one invalid equivalence
class is defined
4) If an input is Boolean then one valid and one invalid equivalence
class is defined
Equivalence Partitioning continued……
Applying guideline for the derivation of equivalences classes test
cases for each input domain data item can be developed and
executed
Consider a banking application in which following input is requires:
area code, prefix, password, command
Following equivalence classes can be formed
Area code: input condition Boolean area code may or may not exists
Input condition range: value defined in particular range
Prefix : input condition range values >200
Input condition value – four digit value
Password : Input condition Boolean, may or may not be present
input condition value – six character string
Command : input condition set – containing command noted
Boundary Value Analysis
A greater number of error occur at the boundaries of input domain
rather than at the “centre”
Boundary value analysis is a test case design technique that
complements equivalence partitioning. Rather than focusing on input
condition BVA derives test cases from output domain as well
Following step are followed
1) If an input condition specifies a range bounded by values a and b
test case should be designed with values of a and b and just above
a and b and just below a and b
2) If the input condition specifies a number of values test case should
be designed that exercise the minimum and maximum numbers.
Values just above and below the maximum and minimum vales are
also to be tested
3) Apply guideline 1 and 2 to output condition
4) If internal data structures have prescribed boundaries be certain to
design test case to exercise the data structure at its boundary
Orthogonal array testing
There are many application in which the input domain is
relatively limited. The number of input parameter is
small and value each parameter may take are clearly
bounded
It is possible to consider every input permutation and
exhaustively test processing of the input domain
However as the number of input values grow and the
number of discrete value for each data item increase
exhaustive testing become impossible
Orthogonal array testing can be applied to problem in
which input domain is relatively small but too large to
accommodate exhaustive testing
This method is useful in finding error associated with
region faults an error category associated with faulty
logic within software component
Testing for Specialized Environment
Architectures and Application
This Include following
Testing GUI’s
Module Interface
Local data structure
~~~~~
Boundary condition
~~~~~
Independent Paths
~~~~~ Error handling Paths
Test
Cases
Unit Testing Consideration continued…..
The module interface is tested to ensure that information properly flows
into and out of program unit under test
All above things are checked for unit testing but they are following one
particular sequence
Unit Testing Consideration continued…..
Data flow across a module interface are required before any test is
initiated . If data do not enter and exit properly all other test are moot
Selective testing of execution path is an essential task during unit
testing. This test should be designed to uncover erroneous computation
Basis path testing are effective techniques for uncovering a broad array
of path error
Test case should uncover error such as
1) Comparisons of data types 2) incorrect logical operators
3) Expectation of equality when precision error makes equality unlikely
4) Incorrect comparison of variables
5) Improper or nonexistent of loop termination
6) Failure to exit when divergent iteration is encountered
7) Improperly modified loop variables
Boundary testing is the last task of unit test step since software often
occur at its boundaries
Unit Testing Procedures
Since a component is not a stand alone program driver and/or stub
software must be developed for each unit test
A driver is nothing more than a main program that accepts test case
data passes such data to the component (to be tested) and prints
relevant result
Stubs serve to replace modules that are subordinate to the component
to be tested. It represent dummy program use the subordinate module
interface may do minimal data manipulation print verification of entry
and return control to module undergoing testing
Driver
Interface
Local data structure
Module to Boundary condition
be Independent Paths
tested Error handling Paths
M1
M2 M3 M4
M5 M6
M7
Integration Testing continued……
Depth first integration would integrate all components vertically
Breadth first will integrate all components directly subordinate at
each level moving across structure horizontally
The integration process is performed as follows
The main control module is used as test driver and stubs are
substituted for all components directly subordinate to main control
module
Depending on integration approach selected subordinate stubs are
replaced one at time with actual components
Test are conducted as each component is integrated
On completion of each set of tests another stub is replaced with
real world component
Regression testing may be conducted to ensure that new error have
not introduce
Integration Testing continued…
Top down integration verifies major control decision in test
process
Decision making occur at upper level in hierarchy and is
therefore encountered first
If depth first search is selected a complete function of
software may be implemented and demonstrated
There are certain problem associated with this approach like
stubs replace lower level module at the beginning of this
method therefore no significant data can flow upward in
program structure
The tester is left with three approach
A series of test is designed to expose errors that will keep the build
from performing properly its function
The build is integrated with other builds and entire product is smoke
tested daily. Integration approach may be top down or bottom up
Validation testing and System testing
It has following criteria for following
Validation test criteria
Configuration review
Alpha and Beta Testing
The card consist of class name , its responsibility (operations) and its
collaborators (other classes to which it sends message and on which it depends
for accomplishment for its responsibilities
Evaluating consistency of Class Model using
CRC
To evaluate the class model following step recommended
1) Revisit the CRC model and object relationship model. Cross check to
ensure that all collaboration implied by the OOA model are properly
Represented
2) Inspect the description of each CRC index card to determine if
delegated responsibility is part of collaboration definition
3) Invert the connection to ensure that each collaborator that is asked
for services is receiving request from a reasonable source
4) Using the inverted connection examined in step 3, determine
whether other classes might be required and whether responsibility
are properly grouped among the classes
5) Determine whether widely requested responsibility might be
combined into single responsibilities
6) Step 1 through 5 are applied iteratively to each model
Evaluating consistency of Class Model
contd…
Once OOD model is created review of system design and object
design has to be conducted
Test case will be designed to check all the above step listed are
correctly executed
Testing Surface Structure
Surface structure refers to the externally observable structure of an OO
program. The structure that is immediately obvious to an end user
The best test case are derived when designer look at the system in a
new or unconventional way
Ask a question like “Might the user want to use this operation which
applies only to Scanner Object while working with the printer?”
Whatever the interface style, test case design that exercise the surface
structure should use both objects and operation as clues leading to
overlooked tasks
Testing Deep structure
Deep structure refers to internal technical details of OO
Program
Deep structure testing is designed to exercise
dependencies behavior and communication mechanism
that have been established as part of system and object
design
Analysis and design model are used as basis for deep
structure testing
For example the object-relationship diagram or the
subsystem collaboration diagram depicts collaboration
between objects and subsystem that may not be
externally visible
The test case design then ask “Have we captured some
task that exercise the collaboration noted on the object-
relationship diagram or the subsystem collaboration
diagram? If not why not?”
Testing Method applicable at the class level
1) Random Testing for OO Classes
Consider a banking application in which an account class has following
operation: open, setup, deposit, withdraw, balance, summarize,
creditlimit and close
Each of these operation may be applied for account but certain
constraint are implied by the nature of problem (account must be open
before doing any specific operation)
Even with these constraint, there many permutation of the operation like
open-setup-deposit-withdraw-close
A variety of different operation sequence can be generated