admin 管理员组

文章数量: 888297

Graph Coverage

一、基本概念

  • Test Requirements (TR) : Describe properties of test paths (描述了测试路径需要的元素)
  • Test Criterion : Rules that define test requirements (定义TR的规则)
  • 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.(Notice: we define “length up to 1” instead of simply “length 1”目的是让所有的图都能具有这几种结构覆盖的定义,包括只有一个节点的图,类似的还有边对覆盖对于只有两个节点的图的情况)

     Edge-Pair Coverage (EPC) : TR contains each reachable path of length up to 2, inclusive, in G. (边对覆盖)

     Complete Path Coverage (CPC) : TR contains all paths in G.  (完全路径覆盖,当然如果路径中有循环则所有情况是不可能完全列举出来,因此CPC并不合理)

     Specified Path Coverage (SPC):指定路径覆盖,即指定测试路径集合S,但是测试路径并不令人满意,因为会随着测试者的变动结果会变得不一样

二、示例

现在可以使用主路径处理循环问题 

三、Simple Paths and Prime Paths (简单路径和主路径)

    Simple Path : A path from node ni to nj is simple if no node appears more than once, except possibly the first and last nodes are the same (无环或者初始节点同时为最后节点)

    Prime Path : A simple path that does not appear as a proper subpath of any other simple path (意思是这一条简单路径不能成为其他简单路径的子路径,我们称这条路径为主路径。)

    Prime Path Coverage:TR contains each prime path in G.(主路径覆盖,将会遍历所有长度为0,1及以上的,意味着包括了点覆盖和边覆盖,但是边对覆盖不是主路径覆盖的子集)

例题

     

【解】

从每一个点向后扩展(也可以向前扩展或者两边扩展)

!表示扩展到结尾或者再向下扩展不再是简单路径,如0123!

*表示扩展到首尾相同

len=0

len=1

len=2

len=3

len=4

0

01

012

0123!

 

015

0156!

 

04

046!

 

 

1

12

123

1231*

 

15

156!

 

 

2

23

231

2312*

 

2315

23156!

3

31

312

3123*

 

315

3156!

 

4

46!

 

 

 

44*

 

 

 

5

56!

 

 

 

6!

 

 

 

 

 Prime Path:

2→3→1→5→6    ,    0→1→2→3    ,    0→1→5→6    ,    1→2→3→1    ,    2→3→1→2    ,    3→1→2→3    ,    0→4→6    ,    4→4

Test Path1:    0→1→2→3→1→2→3→1→5→6

Test Path2:    0→4→4→6

Test Path3:    0→1→5→6

Test Path4:    0→4→6

由于本题从控制流图开始,未给出题目描述,无法给出测试用例。

 输入数据预期输出
测试用例1  
测试用例2  
测试用例3  
测试用例4  

本文标签: Graph Coverage