[软件测试_hw3]路径覆盖测试

一、书后题

(a) 为printPrimes()方法画控制流图

(b) 考虑测试用例t1=(n=3)和t2=(n=5)。即使这些测试用例游历printfPrimes()方法中相同的主路径,他们不一定找出相同的错误。设计一个简单的错误,使得t2比t1

更容易发现。

  答:数组越界

(c) 针对printPrimes()找到一个测试用例,使得相应的测试路径访问连接while语句开始到for语句的边,而不用通过while循环体。

  答:n=1

(d) 针对printPrimes()的图列举每个节点覆盖,边覆盖和主路径覆盖的测试需求

  点覆盖: {1,2,3,4,5,6,7,8,9,10,11,12}

  边覆盖:{(1,2),(2,3),(2,10),(3,4),(4,5),(4,8),(5,6),(5,7),(6,4),(7,8),(8,2),(8,9),(9,2),(10,11),(10,12),(11,10)}

  主路径覆盖: {(1,2,3,4,5,6),

         (1,2,3,4,5,7,8,9),

         (1,2,10,11),

         (1,2,10,12),

         (2,3,4,5,7,8,9,2),

         (2,3,4,5,7,8,2)

         (2,3,4,8,9,2),

         (2,3,4,8,2)

         (3,4,5,7,8,9,2,10,11,12),

         (3,4,5,7,8,9,2,10,11,13),

         (3,4,5,7,8,2,10,11,12),

         (3,4,5,7,8,2,10,11,13),

         (4,5,6,4),

         (4,5,7,8,9,2,3,4),

         (4,5,7,8,2,3,4),

         (4,8,2,3,4),

         (4,8,9,2,3,4),

         (5,6,4,5),

         (5,6,4,8,9,2,10,11,12),

         (5,6,4,8,9,2,10,11,13),

         (5,6,4,8,2,10,11,12),

         (5,6,4,8,2,10,11,13),

         (6,4,5,6),

         (6,4,5,7,8,9,2,10,11,12),

         (6,4,5,7,8,9,2,10,11,13),

         (6,4,5,7,8,2,10,11,12),

         (6,4,5,7,8,2,10,11,13),

         (6,4,5,7,8,9,2,3),

         (6,4,8,9,2,3),

         (7,8,9,2,3,4,5,7),

         (7,8,2,3,4,5,7),

         (8,9,2,3,4,5,7,8),

         (8,2,3,4,5,7,8),

         (8,9,2,3,4,8),

         (8,2,3,4,8),

         (9,2,3,4,5,7,8,9),

         (9,2,3,4,8,9),

         (11,12,11),

         (12,11,12),

         (12,11,13)

}

二、实现主路径覆盖测试

使用实验一中的三角形程序

posted @ 2016-03-30 19:50  种田的萌鸭  阅读(388)  评论(0编辑  收藏  举报