软件测试 Homework3
一、
(a) Draw the control flow graph for the printPrime() method.
(b) Consider test cases t1 = (n = 3) and t2 = ( n = 5). Although these tour the same prime paths in printPrime(), they don't necessarily find the same faults. Design a simple fault that t2 would be more likely to discover than t1 would.
将MAXPRIMES设置为4时,t2会发生数组越界错误,但t1不会发生错误。
(c) For printPrime(), find a test case such that the corresponding test path visits the edge that connects the beginning of the while statement to the for statement without going through the body of the while loop.
当n=1时,不会进入while循环
(d) Enumerate the test requirements for node coverage, edge coverage,and prime path coverage for the path for printPrimes().
点覆盖:{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
边覆盖:{(1,2),(2,3),(3,4),(3,12),(4,5),(5,6),(6,9),(6,7),(7,8),(7,10),(8,9),(9,11),(9,3),(10,6),(11,3),(12,13),(13,14),(14,15),(15,13),(13,16)}
主路径覆盖:{(1,2,3,4,5,6,7,8,9,11),(1,2,3,4,5,6,7,10),(1,2,3,12,13,16),(1,2,3,12,13,14,15),(3,4,5,6,7,8, 9,11,3),(4,5,6,7,8, 9,11,3,4),(5,6,7,8, 9,11,3,4,5),(6,7,10,6),(6,7,8,9,11,3,4,5,6),(7,10,6,7),(7,8,9,11,3,4,5,6,7),(8,9,11,3,4,5,6,7,8),(9,11,3,4,5,6,7,8,9),(10,6,7,10),(11,3,4,5,6,7,8,9,11),(13,14,15,13),(14,15,13,14),(15,13,14,15),(14,15,13,16),(15,13,16)}
二、基于Junit及Eclemma(jacoco)实现一个主路径覆盖的测试
在Lab1中实现主路径覆盖,只需设计三种特殊三角形和一种普通三角形测试用例即可达到100%覆盖。