软件测试作业3
(a) Draw the control flow graph for the printPrime() method.

(b) Consider test cases ti = (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时,t1 = (n = 3) 不会报错,t2 = (n = 5)会出现数组越界的错误。
(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,函数直接跳过循环体。
(d) Enumerate the test requirements for node coverage, edge coverage,and prime path coverage for the path for printPrimes().
NC:
TR : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
EC:
TR:{(1, 2), {2, 3}, {3, 4}, {4, 5}, {5, 7}, {7, 4}, {4, 8}, {5, 6}, {6, 8}, {8, 9}, {8, 2}, {9, 2}, {2, 10}, {10, 11}, {11, 12}, {12, 13}, {13, 11}, {11, 14}}
PPC:
TR:{[1, 2, 3, 4, 8, 9], [1, 2, 3, 4, 5, 6, 8, 9], [1, 2, 3, 4, 5, 7], [1, 2, 10, 11, 14], [1, 2, 10, 11, 12, 13],
[3, 4, 8, 2, 3], [3, 4, 8, 2, 10, 11, 14], [3, 4, 8, 2, 10, 11, 12, 13], [3, 4, 8, 9, 2, 3], [3, 4, 8, 9, 2, 10, 11, 14], [3, 4, 8, 9, 2, 10, 11, 12, 13], [3, 4, 5, 6, 8, 2, 3], [3, 4, 5, 6, 8, 2, 10, 11, 14], [3, 4, 5, 6, 8, 2, 10, 11, 12, 13], [3, 4, 5, 6, 8, 9, 2, 3], [3, 4, 5, 6, 8, 9, 2, 10, 11, 14], [3, 4, 5, 6, 8, 9, 2, 10, 11, 12, 13],
[4, 5, 7, 4], [4, 8, 2, 3, 4], [4, 8, 9, 2, 3, 4],
[5, 6, 8, 2, 3, 4, 5], [5, 6, 8, 9, 2, 3, 4, 5], [5, 7, 4, 5], [5, 7, 4, 8, 2, 3], [5, 7, 4, 8, 9, 2, 3], [5, 7, 4, 8, 2, 10, 11, 14], [5, 7, 4, 8, 9, 2, 10, 11, 14], [5, 7, 4, 8, 2, 10, 11, 12, 13], [5, 7, 4, 8, 9, 2, 10, 11, 12, 13],
[6, 8, 2, 3, 4, 5, 6], [6, 8, 9, 2, 3, 4, 5, 6], [6, 8, 2, 3, 4, 5, 7], [6, 8, 9, 2, 3, 4, 5, 7],
[7, 4, 5, 7], [7, 4, 5, 6, 8, 2, 10, 11, 14], [7, 4, 5, 6, 8, 2, 10, 11, 12, 13], [7, 4, 5, 6, 8, 9, 2, 10, 11, 14], [7, 4, 5, 6, 8, 9, 2, 10, 11, 12, 13], [7, 4, 8, 2, 3], [7, 4, 8, 9, 2, 3],
[8, 2, 3, 4, 8],[8, 2, 3, 4, 5, 6, 8],[8, 9, 2, 3, 4, 8],[8, 9, 2, 3, 4, 5, 6, 8],[8, 2, 3, 4, 5, 7],[8, 9, 2, 3, 4, 5, 7],
[9, 2, 3, 4, 8, 9], [9, 2, 3, 4, 5, 6, 8, 9], [9, 2, 3, 4, 5, 7],
[11, 12, 13, 11],
[12, 13, 11, 12], [12, 13, 11, 14],
[13, 11, 12, 13]}
(e) 基于 Junit 以及 Eclemma (Jacoco) 实现一个主路径覆盖的测试


浙公网安备 33010602011771号