Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,

Similar presentations


Presentation on theme: "CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,"— Presentation transcript:

1 CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis, Winter 2006 Presented by Jiang Wu j32wu@cs.uwaterloo.ca

2 CS447/ECE453/SE465 Prof. Alencar Outline of the 12 tutorials Graphs Tutorial 1 Graphs Tutorial 1 Example Problems Tutorial 2 Example Problems Tutorial 2 Project Kickoff Tutorial 3 Project Kickoff Tutorial 3 Functional TestingTutorial 4, 5 Functional TestingTutorial 4, 5 Structural Testing Tutorial 6, 7, 8 Structural Testing Tutorial 6, 7, 8 Integration TestingTutorial 9, 10 Integration TestingTutorial 9, 10 System testing Tutorial 11 System testing Tutorial 11 Software reliability Tutorial 12 Software reliability Tutorial 12

3 ECE 453 3University of Waterloo Graphs Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

4 ECE 453 4University of Waterloo Agenda  Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

5 ECE 453 5University of Waterloo Undirected Graphs A graph G = (V, E) is composed of a finite (and non-empty) set V = {n 1, n 2,…,n m } of nodes, and a set E = {e 1, e 2,…,e p } of edges, where each edge e k = {n i, n j } for some nodes n i, n j V A graph G = (V, E) is composed of a finite (and non-empty) set V = {n 1, n 2,…,n m } of nodes, and a set E = {e 1, e 2,…,e p } of edges, where each edge e k = {n i, n j } for some nodes n i, n j V Nodes also called vertices Nodes also called vertices Edges also called arcs Edges also called arcs Nodes also called endpoints of an arc Nodes also called endpoints of an arc

6 ECE 453 6University of Waterloo Undirected Graphs Nodes are usually program statements Nodes are usually program statements Edges for flow of control, define/use relationships etc. Edges for flow of control, define/use relationships etc. n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 nodes edge {n 3, n 4 } V = {n 1, n 2, n 3, n 4, n 5, n 6, n 7 } E = {e 1, e 2, e 3, e 4, e 5, e 6, e 7 } = {(n 1, n 2 ), (n 2, n 3 ), (n 1, n 5 ), (n 4, n 5 ), (n 2, n 4 ), (n 3, n 4 ), (n 4, n 6 )}

7 ECE 453 7University of Waterloo Agenda  Undirected Graphs  Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

8 ECE 453 8University of Waterloo Degree of a Node The degree of a node in a graph is the number of edges that have that node as an endpoint. We write deg(n) for the degree of node n. The degree of a node in a graph is the number of edges that have that node as an endpoint. We write deg(n) for the degree of node n. deg(n 1 ) = 2 deg(n 2 ) = 3 deg(n 3 ) = 2 deg(n 4 ) = 4 deg(n 5 ) = 2 deg(n 6 ) = 1 deg(n 7 ) = 0 n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7

9 ECE 453 9University of Waterloo Agenda  Undirected Graphs Degree of a Node Degree of a Node  Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

10 ECE 453 10University of Waterloo Incidence Matrices Alternative representation of graphs Alternative representation of graphs The incidence matrix of a graph G = (V, E) with m nodes and n edges is an m x n matrix, where the element in row i, column j is 1 if and only if node i is an endpoint of edge j, otherwise the element is 0 The incidence matrix of a graph G = (V, E) with m nodes and n edges is an m x n matrix, where the element in row i, column j is 1 if and only if node i is an endpoint of edge j, otherwise the element is 0

11 ECE 453 11University of Waterloo Incidence Matrices n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 Sum of a row: degree Sum of a column:2

12 ECE 453 12University of Waterloo Incidence Matrices The sum of the entries in any column is 2 The sum of the entries in any column is 2 It is a form of integrity checking It is a form of integrity checking The row sum is the degree of the node The row sum is the degree of the node When zero, the node is isolated (unreachable code, objects never used) When zero, the node is isolated (unreachable code, objects never used)

13 ECE 453 13University of Waterloo Agenda  Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices  Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

14 ECE 453 14University of Waterloo Adjacency Matrices Useful supplement to the incidence matrix Useful supplement to the incidence matrix The adjacency matrix of a graph G=(V, E) with m nodes is an m x m matrix, where the element in row i, column j is a 1 if and only if there is an edge between node i and node j, otherwise the element is 0 The adjacency matrix of a graph G=(V, E) with m nodes is an m x m matrix, where the element in row i, column j is a 1 if and only if there is an edge between node i and node j, otherwise the element is 0 Symmetric: element (i, j) = element (j, i) Symmetric: element (i, j) = element (j, i) The row sum is the degree of the node The row sum is the degree of the node

15 ECE 453 15University of Waterloo Adjacency Matrices n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 Symmetric

16 ECE 453 16University of Waterloo Agenda  Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices  Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

17 ECE 453 17University of Waterloo Paths A path is a sequence of edges such that, for any adjacent pair of edges e i, e j in the sequence, the edges share a common (node) endpoint A path is a sequence of edges such that, for any adjacent pair of edges e i, e j in the sequence, the edges share a common (node) endpoint Sequences of nodes or sequences of edges Sequences of nodes or sequences of edges

18 ECE 453 18University of Waterloo Paths n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7

19 ECE 453 19University of Waterloo Paths If we multiply an adjacency matrix with itself the product will show the number of all two edge paths of the graph. If we further multiply the product with the original adjacency matrix the new product will show the number of all three edge paths of the graph If we multiply an adjacency matrix with itself the product will show the number of all two edge paths of the graph. If we further multiply the product with the original adjacency matrix the new product will show the number of all three edge paths of the graph = 2

20 ECE 453 20University of Waterloo Agenda  Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths  Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

21 ECE 453 21University of Waterloo Connectedness Nodes n i and n j are connected if and only if they are in the same path Nodes n i and n j are connected if and only if they are in the same path Connectedness is an equivalence relation on the node set of a graph Connectedness is an equivalence relation on the node set of a graph Reflexive: every node is in a path of length 0 with itself Reflexive: every node is in a path of length 0 with itself Symmetric: if (n i, n j) path, then (n j, n i ) path Symmetric: if (n i, n j) path, then (n j, n i ) path Transitive: if (n i, n j ) path and (n j, n w ) path, then (n i, n w ) path Transitive: if (n i, n j ) path and (n j, n w ) path, then (n i, n w ) path

22 ECE 453 22University of Waterloo Connectedness Equivalence relations induce a partition Equivalence relations induce a partition Connectedness defines a partition on the node set of a graph Connectedness defines a partition on the node set of a graph A component of a graph is a maximal set of connected nodes A component of a graph is a maximal set of connected nodes n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 {n1, n2, n3, n4, n5, n6}, {n7} {n1, n2} is not a component

23 ECE 453 23University of Waterloo Agenda  Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness  Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

24 ECE 453 24University of Waterloo Condensation Graphs Given a graph G = (V, E), its condensation graph is formed by replacing each component by a condensing node Given a graph G = (V, E), its condensation graph is formed by replacing each component by a condensing node n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 → S 1 = {n 1, n 2, n 3, n 4, n 5, n 6 } S 2 = {n 7 }

25 ECE 453 25University of Waterloo Agenda  Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs  Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

26 ECE 453 26University of Waterloo Cyclomatic Number The cyclomatic number of a graph G is given by V(G) = e – n + p, e: number of edges, n: number of nodes, p: number of components The cyclomatic number of a graph G is given by V(G) = e – n + p, e: number of edges, n: number of nodes, p: number of components Number of distinct regions in a graph Number of distinct regions in a graph n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 Cyclomatic Number: 7 – 7 + 2 = 2

27 ECE 453 Cyclomatic Number 200

28 ECE 453 28University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

29 ECE 453 29University of Waterloo Directed Graphs A directed graph (digraph) D = (V, E) consists of a finite set V = {n 1, n 2,…,n m } of nodes, and a set E = {e 1, e 2,…,e p } of edges, where each edge e k = is an ordered pair of nodes n i, n j V A directed graph (digraph) D = (V, E) consists of a finite set V = {n 1, n 2,…,n m } of nodes, and a set E = {e 1, e 2,…,e p } of edges, where each edge e k = is an ordered pair of nodes n i, n j V n i : initial (start) node, n j terminal (finish) node n i : initial (start) node, n j terminal (finish) node Software concepts represented with directed graphs: sequential behavior, time- ordered events, messages etc. Software concepts represented with directed graphs: sequential behavior, time- ordered events, messages etc.

30 ECE 453 30University of Waterloo Directed Graphs n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 V = {n 1, n 2, n 3, n 4, n 5, n 6, n 7 } E = {e 1, e 2, e 3, e 4, e 5, e 6, e 7 } = {,,,,,, }

31 ECE 453 31University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs  Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

32 ECE 453 32University of Waterloo Indegrees and Outdegrees The indegree of a node in a directed graph is the number of distinct edges that have the node as a terminal node (indeg(n)) The indegree of a node in a directed graph is the number of distinct edges that have the node as a terminal node (indeg(n)) The outdegree of a node in a directed graph is the number of distinct edges that have the node as an start point (outdeg(n)) The outdegree of a node in a directed graph is the number of distinct edges that have the node as an start point (outdeg(n)) deg(n) = indeg(n) + outdeg(n) deg(n) = indeg(n) + outdeg(n)

33 ECE 453 33University of Waterloo Indegrees and Outdegrees n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 indeg(n 1 ) = 0 indeg(n 2 ) = 2 indeg(n 3 ) = 1 indeg(n 4 ) = 2 indeg(n 5 ) = 1 indeg(n 6 ) = 1 indeg(n 7 ) = 0 outdeg(n 1 ) = 1 outdeg(n 2 ) = 2 outdeg(n 3 ) = 1 outdeg(n 4 ) = 2 outdeg(n 5 ) = 1 outdeg(n 6 ) = 0 outdeg(n 7 ) = 0

34 ECE 453 34University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees  Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

35 ECE 453 35University of Waterloo Types of Nodes Source Node: indegree = 0 Source Node: indegree = 0 Sink Node: outdegree = 0 Sink Node: outdegree = 0 Transfer Node: indegree ≠ 0 && outdegree ≠ 0 Transfer Node: indegree ≠ 0 && outdegree ≠ 0 Isolated Node: indegree = 0 && outdegree = 0 Isolated Node: indegree = 0 && outdegree = 0 External Entities: Source and Sink Nodes External Entities: Source and Sink Nodes

36 ECE 453 36University of Waterloo Types of Nodes Source Nodes: n 1 Sink Nodes: n 6 Transfer Nodes: n 2, n 3, n 4, n 5 Isolated Nodes: n 7 n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7

37 ECE 453 37University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes  Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

38 ECE 453 38University of Waterloo Adjacency Matrix of a Directed Graph The adjacency matrix of a directed graph D = (V, E) with m nodes is a m x m matrix A=(a(i, j)), where a(i, j) is a 1 if and only if there is an edge from node i and node j, otherwise the element is 0 The adjacency matrix of a directed graph D = (V, E) with m nodes is a m x m matrix A=(a(i, j)), where a(i, j) is a 1 if and only if there is an edge from node i and node j, otherwise the element is 0 Not necessarily symmetric Not necessarily symmetric Row sum = outdegree of node Row sum = outdegree of node Column sum = indegree of node Column sum = indegree of node

39 ECE 453 39University of Waterloo Adjacency Matrix of a Directed Graph n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7

40 ECE 453 40University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph  Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

41 ECE 453 41University of Waterloo Paths and Semi – Paths A (directed) path is a sequence of edges such that, for any adjacent pair of edges e i, e j, in the sequence, the terminal node of the first edge is the initial node of the second edge A (directed) path is a sequence of edges such that, for any adjacent pair of edges e i, e j, in the sequence, the terminal node of the first edge is the initial node of the second edge A cycle is a directed path that begins and ends at the same node A cycle is a directed path that begins and ends at the same node A (directed) semi – path is a sequence of edges such that, for at least one adjacent pair of edges e i, e j in the sequence, the initial node of the first edge is the initial node of the second edge or the terminal node of the first edge is the terminal node of the second edge A (directed) semi – path is a sequence of edges such that, for at least one adjacent pair of edges e i, e j in the sequence, the initial node of the first edge is the initial node of the second edge or the terminal node of the first edge is the terminal node of the second edge

42 ECE 453 42University of Waterloo Paths and Semi – Paths Directed paths also called chains Directed paths also called chains n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 Path: n 1 → n 2 → n 3 Cycle: n 2 → n 4 → n 5 → n 2 Semi – Path: e 1, e 3 Semi – Path: e 2, e 5

43 ECE 453 43University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths  Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

44 ECE 453 44University of Waterloo Reachability Matrix The reachability matrix of a directed graph D = (V, E) with m nodes is a m x m matrix R = (r(i, j)), where r(i, j) is a 1 if and only if there is a path from node i and node j, otherwise the element is 0 The reachability matrix of a directed graph D = (V, E) with m nodes is a m x m matrix R = (r(i, j)), where r(i, j) is a 1 if and only if there is a path from node i and node j, otherwise the element is 0

45 ECE 453 45University of Waterloo Reachability Matrix n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7

46 ECE 453 46University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix  N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

47 ECE 453 47University of Waterloo N – Connectedness Two nodes n i and n j in a directed graph are: Two nodes n i and n j in a directed graph are: 0-connected iff there is no path between n i and n j 0-connected iff there is no path between n i and n j 1-connected iff there is a semi-path but NO path between n i and n j 1-connected iff there is a semi-path but NO path between n i and n j 2-connected iff there is a path between n i and n j 2-connected iff there is a path between n i and n j 3-connected iff there is a path from n j to n i and a path from n i to n j 3-connected iff there is a path from n j to n i and a path from n i to n j

48 ECE 453 48University of Waterloo N – Connectedness n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 n1 and n7 are 0-connected n1 and n8 are 1-connected n2 and n6 are 2-connected n3 and n5 are 3-connected n8n8

49 ECE 453 49University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number  Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness  Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

50 ECE 453 50University of Waterloo Strong Components A strong component of a directed graph is a maximal set of 3-connected nodes A strong component of a directed graph is a maximal set of 3-connected nodes Practically loops and isolated nodes are removed and replaced by strong components (directed acyclic graphs) Practically loops and isolated nodes are removed and replaced by strong components (directed acyclic graphs)

51 ECE 453 51University of Waterloo Condensation Graphs → S 1 = {n 2, n 3, n 4, n 5 } S 2 = {n 7 } n1n1 n5n5 n2n2 n3n3 n4n4 n6n6 n7n7 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 n1n1 S1S1 n6n6 S2S2 e1e1 e7e7

52 ECE 453 52University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components  Graphs for Testing  Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

53 ECE 453 53University of Waterloo Program Graphs A program graph is a directed graph in which: A program graph is a directed graph in which: Traditional Definition: Nodes are program statements, and edges represent flow of control (there is an edge from node i to node j iff the statement corresponding to node j can be executed immediately after the statement corresponding to node i) Traditional Definition: Nodes are program statements, and edges represent flow of control (there is an edge from node i to node j iff the statement corresponding to node j can be executed immediately after the statement corresponding to node i) Improved Definition: Nodes are either entire statements or fragments of a statement, and edges represent flow of control (there is an edge from node i to node j iff the statement or statement fragment corresponding to node j can be executed immediately after the statement or statement fragment corresponding to node i) Improved Definition: Nodes are either entire statements or fragments of a statement, and edges represent flow of control (there is an edge from node i to node j iff the statement or statement fragment corresponding to node j can be executed immediately after the statement or statement fragment corresponding to node i) Primarily used at the unit testing level Primarily used at the unit testing level

54 ECE 453 54University of Waterloo Program Graphs

55 ECE 453 55University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components  Graphs for Testing Program Graphs Program Graphs  Finite State Machines Petri Nets Petri Nets

56 ECE 453 56University of Waterloo Finite State Machines A Finite State Machine (FSM) is a directed graph (S, T, Ev, Act), in which A Finite State Machine (FSM) is a directed graph (S, T, Ev, Act), in which S: set of nodes (states) S: set of nodes (states) T: set of edges (transitions) T: set of edges (transitions) Ev, Act: sets of events and actions associated with the transitions in T Ev, Act: sets of events and actions associated with the transitions in T Primarily used to describe system level behavior Primarily used to describe system level behavior

57 ECE 453 57University of Waterloo Finite State Machines Example: Lamp Example: Lamp NodeTransition

58 ECE 453 58University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components  Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines  Petri Nets

59 ECE 453 59University of Waterloo Petri Nets A Petri net is a bipartite directed graph (P, T, In, Out), in which A Petri net is a bipartite directed graph (P, T, In, Out), in which P (places), T (transitions): disjoint sets of nodes P (places), T (transitions): disjoint sets of nodes In, Out: sets of edges, where In P x T, and Out T x P In, Out: sets of edges, where In P x T, and Out T x P Primarily used to describe system level behavior Primarily used to describe system level behavior

60 ECE 453 60University of Waterloo Petri Nets P = {p 1, p 2, p 3, p 4 } T = {t 1, t 2, t 3 } In = {,,, } Out = {,, }

61 ECE 453 61University of Waterloo Petri Nets A marked Petri net is a 5-tuple (P, T, In, Out, M) in which (P, T, In, Out) is a Petri net and M (marking set) is a set of mappings of places to positive integers A marked Petri net is a 5-tuple (P, T, In, Out, M) in which (P, T, In, Out) is a Petri net and M (marking set) is a set of mappings of places to positive integers The number associated with a place refers to the number of tokens that are said to be “in” the place The number associated with a place refers to the number of tokens that are said to be “in” the place e.g. number of times a place has been used e.g. number of times a place has been used

62 ECE 453 62University of Waterloo Petri Nets P = {p 1, p 2, p 3, p 4 } T = {t 1, t 2, t 3 } In = {,,, } Out = {,, } M = {2, 0, 1, 3}

63 ECE 453 63University of Waterloo Petri Nets A transition in a Petri net is enabled if there is at least one token in each of its input places A transition in a Petri net is enabled if there is at least one token in each of its input places Enabled Transitions: t 1, t 3

64 ECE 453 64University of Waterloo Petri Nets When an enabled Petri net transition fires, one token is removed from each of its input places, and one token is added to each of its output places When an enabled Petri net transition fires, one token is removed from each of its input places, and one token is added to each of its output places

65 ECE 453 65University of Waterloo Petri Nets → t 3 fired M = {, }

66 ECE 453 66University of Waterloo Petri Nets Conservative Petri nets: total number of tokens never changes Conservative Petri nets: total number of tokens never changes Petri net conflicts Petri net conflicts Transitions t 1 and t 2 are in conflict with respect to place p 1

67 ECE 453 Petri Net Example http://www.informatik.uni- hamburg.de/TGI/PetriNets/introductions/a alst/elevator1.swf http://www.informatik.uni- hamburg.de/TGI/PetriNets/introductions/a alst/elevator1.swf http://www.informatik.uni- hamburg.de/TGI/PetriNets/introductions/a alst/elevator1.swf http://www.informatik.uni- hamburg.de/TGI/PetriNets/introductions/a alst/elevator1.swf

68 ECE 453 68University of Waterloo Agenda Undirected Graphs Undirected Graphs Degree of a Node Degree of a Node Incidence Matrices Incidence Matrices Adjacency Matrices Adjacency Matrices Paths Paths Connectedness Connectedness Condensation Graphs Condensation Graphs Cyclomatic Number Cyclomatic Number Directed Graphs Directed Graphs Indegrees and Outdegrees Indegrees and Outdegrees Types of Nodes Types of Nodes Adjacency Matrix of a Directed Graph Adjacency Matrix of a Directed Graph Paths and Semi – Paths Paths and Semi – Paths Reachability Matrix Reachability Matrix N – Connectedness N – Connectedness Strong Components Strong Components Graphs for Testing Graphs for Testing Program Graphs Program Graphs Finite State Machines Finite State Machines Petri Nets Petri Nets

69 ECE 453 69University of Waterloo References Software Testing A Craftsman's Approach 2nd edition, Paul C. Jorgensen, CRC Press Software Testing A Craftsman's Approach 2nd edition, Paul C. Jorgensen, CRC Press


Download ppt "CS447/ECE453/SE465 Prof. Alencar University of Waterloo 1 CS447/ECE453/SE465 Software Testing Tutorial Winter 2008 Based on the tutorials by Prof. Kontogiannis,"

Similar presentations


Ads by Google