首页 > 代码库 > 软件测试-chapte4-Graph Coverage
软件测试-chapte4-Graph Coverage
1.Outline
?Introduction to Graph Coverage
? Graph Coverage Criteria
? Control Flow Graph Coverage
? Data Flow Graph Coverage
2.图在软件测试中应用广泛,并且图的来源有:
– Control flow graphs (控制流图)
– Design structure(设计结构)
– FSMs and statecharts(有限状态自动机(FSM "finite state machine" )和 状态转换图)
– Use cases (测试用例)
测试意图通过某种方式覆盖整个图的所有方面
3.图的定义
? A set N of nodes, N is not empty
? A set N0 of initial nodes, N0 is not empty(注意起始节点不能为空,意思是图中必定出现只有后继没有前驱的节点)
如 而不是
? A set Nf of final nodes, Nf is not empty (终结点不为空)
? A set E of edges, each edge from one node to another – ( ni , nj ), i is predecessor, j is successor(i为前驱,j为后继)
4. 图的path
path:A sequence of nodes – [n1, n2, …, nM]
并且每一对节点都是一条边
Length : The number of edges – A single node is a path of length 0 (单节点也是有长度的为0)
Subpath : A subsequence of nodes in p is a subpath of p
Reach (n) : Subgraph that can be reached from n (从n可以到达的子图)
5. Test Paths and SESEs (测试路径和单入单出路径)
Test Path : A path that starts at an initial node and ends at a final node (包含初始结点和终结点)
Test paths represent execution of test cases 测试路径意味着测试用例的执行,但是一些测试用例可能不能覆盖到所有的测试路径
– Some test paths can be executed by many tests
– Some test paths cannot be executed by any tests
SESE graphs : All test paths start at a single node and end at another node (初始和终结点不同,因此至少两个节点)
6. Visiting and Touring
Visit : A test path p visits node n if n is in p (测试路径中的单个节点或边)
Tour : A test path p tours subpath q if q is a subpath of p(测试路径中的子路径)
7. Tests and Test Paths
? path (t) : The test path executed by test t
? path (T) : The set of test paths executed by the set
并且每一个测试(这里相当于一次具体的测试用例)只能去测试一条测试路径
– Syntactic reach : A subpath exists in the graph (语法到达,从测试路径图上看可以到达)
– Semantic reach : A test exists that can execute that subpath(语义到达,设计的一组测试用例能够执行该条测试路径)
GRAPH COVERAGE CRITERIA (图的覆盖标准)
1.Testing and Covering Graphs (2.2)
? Test Requirements (TR) : Describe properties of test paths (描述了测试路径需要满足的条件)
? Test Criterion : Rules that define test requirements ()
? Satisfaction : Given a set TR of test requirements for a criterion C, a set of tests T satisfies C on a graph if and only if for every test requirement in TR, there is a test path in path(T) that meets the test requirement tr
? Structural Coverage Criteria : Defined on a graph just in terms of nodes and edges
? Data Flow Coverage Criteria : Requires a graph to be annotated with references to variables
几种结构覆盖:
Node Coverage (NC) :节点覆盖的TR中必须包含图G中每个可达的节点
Edge Coverage (EC) : TR contains each reachable path of length up to 1, inclusive, in G.(注意:边覆盖TR必须包括每条可达的测试路径而且它的长度至少最多是1,这句话并不是说边覆盖就包含了节点覆盖,它们是不同的,因为当图只包含一个节点时,为了边覆盖的定义不得不作出节点长度为0这样折中的方案,意思是让所有的图都能具有这几种结构覆盖的定义,包括只有一个节点的图,类似的还有边对覆盖对于只有两个节点的图的情况)
Edge-Pair Coverage (EPC) : TR contains each reachable path of length up to 2, inclusive, in G. (边对覆盖包含至少两条长度为2的测试路径)
Complete Path Coverage (CPC) : TR contains all paths in G. (完全路径覆盖,当然如果路径中有循环则所有情况是不可能完全列举出来)
Specified Path Coverage (SPC):指定路径覆盖,即指定测试路径集合S
示例:
软件测试-chapte4-Graph Coverage