Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views

Topics Covered: Lesson 25

Uploaded by

Srawan Nath
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Topics Covered: Lesson 25

Uploaded by

Srawan Nath
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SOFTWARE ENGINEERING TECHNIQUES

LESSON 25:

Topics Covered 4. By methodically tracing state conditions in the graph, the


Cause effect graph testing, Structural testing/White box testing, graph is converted into a limited entry decision table. Each
Basis Path testing, Cyclomatic complexity column in the table represents a test case.
Objectives 5. The columns in the decision table are converted into test
Upon completion of this Lesson, you should be able to: cases.
• Know what is cause effect graph testing The basic notation for the graph is shown in figure
• Know what is structural testing/ white box testing
• Know what is basis path testingv Know what is cyclomatic
complexity
Today let us see two other methods of functional/black box
testing. They are cause effect graph testing and decision table
testing.
Cause Effect Graph Testing
One weakness with the equivalence class partitioning and
boundary value method is that they consider each input
separately. That is, both concentrate on the conditions and
classes of one input. They do not consider combinations of
input circumstances that may form interesting situations that
should be tested. One way to exercise combinations of different
input conditions is to consider all valid combinations of the White Box Testing
equivalence classes of input conditions. This simple approach This testing technique takes into account the internal structure
will result in an unusually large number of test cases, many of of the system or component. The entire source code of the
which will not be useful for revealing any new errors. For system must be available. This technique is known as white box
example, if there are n different input conditions, such that any testing because the complete internal structure and working of
combination of the input conditions is valid, we will have 2n the code is available.
test cases. White box testing helps to derive test cases to ensure:
Cause effect graphing [ELME73) is a technique that aids in 1. All independent paths are exercised at least once.
selecting, in a systematic way, a high - yield set of test cases. It 2. All logical decisions are exercised for both true and false
has a beneficial effect in pointing out incompleteness and paths.
ambiguities in the specifications. The following process is used
3. All loops are executed at their boundaries and within
to derive test cases [MYER 79].
operational bounds.
1. The causes & effects in the specifications are identified. A
4. All internal data structures are exercised to ensure validity.
cause is a distinct input condition or an equivalence class of
input conditions. An effect is an output condition or a White box testing helps to:
system transformation (a lingering effect that an input has • Traverse complicated loop structures
on the state of the program or system). For instance, if a • Cover common data areas,
transaction to a program causes a master file to be updated,
• Cover control structures and sub-routines,
the alteration to the master file is a system transformation;
a confirmation message would be an output condition. • Evaluate different execution paths
Causes and effects are identified by reading the specification • Test the module and integration of many modules
word-by-word and underlining words or phrases that • Discover logical errors, if any.
describe causes & effects. Each cause & effect is assigned a
• Helps to understand the code
unique number.
Why the white box testing is used to test conformance to
2. The semantic content of the specification is analyzed and
requirements?
transformed into a Boolean graph linking the causes and
effects. This is the cause effect graph. • Logic errors and incorrect assumptions most likely to be
made when coding for “special cases”. Need to ensure these
3. The graph is annotated with constraints describing
execution paths are tested.
combinations of causes and/or effects that are impossible
because of syntactic or environmental constraints

© Copy Right: Rai University


3E.253 89
• May find assumptions about execution paths incorrect, and An independent path is any path through a program that
SOFTWARE ENGINEERING TECHNIQUES

so make design errors. White box testing can find these introduces at least one new set of processing statements or a
errors. new condition (i.e., a new edge)
• Typographical errors are random. Just as likely to be on an
obscure logical path as on a mainstream path.
“Bugs lurk in corners and congregate at boundaries”
Basis Path Testing
A testing mechanism proposed by McCabe.
Aim is to derive a logical complexity measure of a procedural
design and use this as a guide for defining a basic set of
execution paths.
Test cases, which exercise basic set, will execute every statement
at least once.
Flow Graph Notation
Flow graph notation helps to represent various control
structures of any programming language. Various notations for
representing control flow are:

Fig 3.3: Sample program and corresponding flow diagram


In Fig 3.3, the statements are numbered and the corresponding
nodes also numbered with the same number. The sample
program contains one DO and three nested IF statements.
From the example we can observe that:
Fig 3.1: Notations used for control structures • Cyclomatic Complexity of 4 can be calculated as:
On a Fow Graph 1. Number of regions of flow graph, which is 4.
• Arrows called edges represent flow of control 2. #Edges - #Nodes + 2, which is 11-9+2=4.
• Circles called nodes represent one or more actions. 3. #Predicate Nodes + 1, which is 3+1=4.
• Areas bounded by edges and nodes called regions. The above complexity provides the upper bound on the
• A predicate node is a node containing a condition number of tests cases to be generated or independent execution
paths in the program. The independent paths(4 paths) for the
Any procedural design/ program can be translated into a flow
program shown in fig 3.3 is given below:
graph. Later the flow graph can be analyzed for various paths
within it. • Independent Paths
Note that compound Boolean expressions at tests generate at 1. 1, 8
least two predicate node and additional arcs. 2. 1, 2, 3, 7b, 1, 8
Example 3. 1, 2, 4, 5, 7a, 7b, 1, 8
4. 1, 2, 4, 6, 7a, 7b, 1, 8
Cyclomatic complexity provides upper bound for number of
tests required to guarantee the coverage of all program state-
ments.
Deriving Test Cases
Test cases are designed in many ways. The steps involved for
test case design are:
1. Using the design or code, draw the corresponding flow
graph.
2. Determine the cyclomatic complexity of the flow graph.
Fig 3.2: Control flow of a program and the corresponding
flow diagram 3. Determine a basis set of independent paths.

Cyclomatic Complexity 4. Prepare test cases that will force execution of each path in
The cyclomatic complexity gives a quantitative measure of the the basis set.
logical complexity. This value gives the number of independent Note: some paths may only be able to be executed as part of
paths in the basis set, and an upper bound for the number of another test.
tests to ensure that each statement is executed at least once.

© Copy Right: Rai University


90 3E.253
Graph Matrices

SOFTWARE ENGINEERING TECHNIQUES


Graph matrices can automate derivation of flow graph and
determination of a set of basis paths. Software tools to do this
can use a graph matrix. A sample graph matrix is shown is Fig
3.4.
The Graph Matrix
• Is a square matrix with number of sides equal to number
of nodes.
• Rows and columns of the matrix correspond to the
number of nodes in the flow graph.
• Entries correspond to the edges.
The matrix can associate a number with each entry of the edge.
Use a value of 1 to calculate the cyclomatic complexity. The
cyclomatic complexity is calculated as follows:
• For each row, sum column values and subtract 1.
• Sum these totals and add 1.
Which is 4.
Some other interesting link weight can be measured by the
graph as
• Probability that a link (edge) will be executed
• Processing time for traversal of a link
• Memory required during traversal of a link
• Resources required during traversal of a link

Fig 3.4: Example of a graph matrix


Notes

© Copy Right: Rai University


3E.253 91

You might also like