0% found this document useful (0 votes)
55 views10 pages

Lab12 PDF

Uploaded by

Vince Kao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views10 pages

Lab12 PDF

Uploaded by

Vince Kao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

CSE4006: Software Engineering

Lab 12: Testing(2)


Software Engineering Lab

Except where otherwise noted, the contents of this document are Copyright 2017 Gwanggyu Choi, Youn-geun
Ahn and Scott Uk-Jin Lee All rights reserved. Any redistribution, reproduction, transmission, or storage of part
or all of the contents in any form is prohibited without author’s expressed written permission.
White-box Testing
Testing should be designed under these philosophies
• Guarantee that all independent paths within a module have been
executed at least once.
• Execute all logical decisions on their true and false sides.
• Execute all loops at their boundaries and within their operational
bounds.
• Execute internal data structures to ensure their validity.
Basis Path Testing
Basis path testing is a white-box method for designing
test cases.
• The method analyzes the control flow graph of a program to find a
set of linearly independent paths of execution.
• The method uses McCabe’s cyclomatic complexity to determine
the number of linearly independent paths and then generate test
cases for each path thus obtained.
Control Flow Graph Notation
The flow graph depicts logical control flow
• Lines called edges represent flow of control
• Circles called nodes represent one or more actions
• Areas bounded by edges and nodes called regions
• A predicate node is a node containing a condition
Control Flow Graph Example
Calculate Cyclomatic Complexity
Cyclomatic complexity is a software metric that, used to
indicate the complexity of a program.

Complexity is computed in one of three ways.

• Cyclomatic complexity V(G) for a graph G is defined as:


V(G) = E – N + 2*U
E: the number of edges, N: the number of nodes,
U: the number of unconnected graph

• V(G) also defined as:


V(G) = P + 1
P: the number of predicate nodes
/ or the number of regions
Calculate Cyclomatic Complexity

Calculate with edges and nodes


V(G) = 14 edges – 11 nodes + 2 = 5
1
Calculate with predicate nodes
2 V(G) = |{(1), (2), (67), (68 or 9)}| + 1 = 5

Calculate with regions


V(G) = |[1], [2], [3], [4]| + 1 = 5
3 4

6
7 .

8 9
Determine a Basis paths set

Path 1: 1  11

Path 2: 1  2  3  5  6  7  10  1  11

Path 3: 1  2  3  5  6  8  10  1  11

Path 4: 1  2  3  5  6  9  10  1  11

Path 5: 1  2  4  5  6  9  10  1  11

Path X: 1  2  3  5  6  7  10  1  2
 3  5  6  8  10  1  2  4 
5  6  9  10  1  11
Exercise 1. Basis Path Testing
Using pseudo code for bubble sort
1. Draw Control Flow Graph
2. Calculate Cyclomatic Complexity
3. Determine a basis set of paths
Submission
1. Take a picture your
CFG, Cyclomatic complexity, Basis Paths.
(if you draw them to computer, capture them)

2. Image file name : [Lab12]Yourname.png

3. Send [email protected]
(mail title: [Lab12]Yourname)

Due Date: 6/11(Sun) 11:59pm

You might also like