标签:body art 问题 with appear code set ted 用例
1.回答书上63-64页printPrimes()问题a-d:
a:本题控制流图如下图1所示
为查看方便,利用图2进行答题
图1 图2
b:
我们注意到代码第十行有int [] primes = new int [MAXPRIMES]
若在程序中设置MAXPRIMES = 4,那么当运行t1时不会出错误,但是在运行t2时会出现数组越界错。
c:
设计一个不经过while循环体的测试用例
t3 = (n=1或0)
d:
Node coverage:
TR = {1,2,3,4,5,6,7,8,9,10,11,12,13,14}
Test Paths: [1,2,3,4,5,7,4,6,8,9,10,2,11,12,13,12,14]
Edge coverage:
TR= {[1,2],[2,3],[2,11],[3,4],[4,5],[4,6],[5,6],[5,7],[6,8],[7,4],[8,9][8,10],
[9,10],[10,2],[11,12],[12,13],[12,14],[13,12]}
Test Paths: i.[1,2,3,4,5,7,4,6,8,9,10,2,11,12,13,12,14]
ii.[1,2,3,4,5,6,8,10,2,11,12,14]
Prime path coverage:
TR={ [12,13,12],[13,12,13],[4,5,7,4],[5,7,4,5],[7,4,5,7],[2,3,4,6,8,10,2],
[3,4,6,8,10,2,3],[4,6,8,10,2,3,4],[6,8,10,2,3,4,6],[8,10,2,3,4,6,8],
[10,2,3,4,6,8,10],[2,3,4,5,6,8,10,2],[2,3,4,6,8,9,10,2],
[3,4,5,6,8,10,2,3],[3,4,6,8,9,10,2,3],[4,5,6,8,10,2,3,4],
[4,6,8,9,10,2,3,4],[5,6,8,10,2,3,4,5],[6,8,9,10,2,3,4,6],
[6,8,10,2,3,4,5,6],[8,9,10,2,3,4,6,8],[8,10,2,3,4,5,6,8],
[9,10,2,3,4,6,8,9],[10,2,3,4,5,6,8,10],[10,2,3,4,6,8,9,10],
[2,3,4,5,6,8,9,10,2],[3,4,5,6,8,9,10,2,3],[4,5,6,8,9,10,2,3,4],
[5,6,8,9,10,2,3,4,5],[6,8,9,10,2,3,4,5,6],[8,9,10,2,3,4,5,6,8],
[9,10,2,3,4,5,6,8,9],[10,2,3,4,5,6,8,9,10],
[1,2,11,12,13],[1,2,11,12,14],[1,2,3,4,5,7],[1,2,3,4,6,8,10],
[1,2,3,4,5,6,8,10],[1,2,3,4,6,8,9,10],[5,7,4,6,8,10,2,3],
[6,8,10,2,3,4,5,7],[7,4,5,6,8,10,2,3],[1,2,3,4,5,6,8,9,10],
[3,4,6,8,10,2,11,12,13],[3,4,6,8,10,2,11,12,14],[5,7,4,6,8,9,10,2,3]
[6,8,9,10,2,3,4,5,7],[7,4,5,6,8,9,10,2,3],[3,4,5,6,8,10,2,11,12,14],
[3,4,5,6,8,10,2,11,12,13],[3,4,6,8,9,10,2,11,12,13],
[3,4,6,8,9,10,2,11,12,14],[5,7,4,6,8,10,2,11,12,13],
[5,7,4,6,8,10,2,11,12,14],[7,4,5,6,8,10,2,11,12,13],
[7,4,5,6,8,10,2,11,12,14],[3,4,5,6,8,9,10,2,11,12,13],
[3,4,5,6,8,9,10,2,11,12,14],[5,7,4,6,8,9,10,2,11,12,13],
[5,7,4,6,8,9,10,2,11,12,14],[7,4,5,6,8,9,10,2,11,12,13],
[7,4,5,6,8,9,10,2,11,12,14]
}
2.根据上题编写一个主路径覆盖测试
我对于书上的源程序上做了修改,测试代码如下:
测试结果如下图:
此次作业代码已上传至github:
https://github.com/humengdne/ST-Homeworks/tree/master/HW03
英文版:
1. Answering printPrimes () questions a-d on book pages 63-64 :
A: The control flow chart is shown in Figure 1 below
To view conveniently, use Figure 2 to answer:
Figure 1 Figure 2
b:
We noted that int [] primes = new int [MAXPRIMES] at the 10th line at code.
If I set MAXPRIMES = 4, there will be a failure in t2, which is caused by Array crosses. But the failure will not appear when t1 is running.
c:
Design a test case without going through a while loop body
t3 = (n=1或0)
d:
Node coverage:
TR = {1,2,3,4,5,6,7,8,9,10,11,12,13,14}
Test Paths: [1,2,3,4,5,7,4,6,8,9,10,2,11,12,13,12,14]
Edge coverage:
TR= {[1,2],[2,3],[2,11],[3,4],[4,5],[4,6],[5,6],[5,7],[6,8],[7,4],[8,9][8,10],
[9,10],[10,2],[11,12],[12,13],[12,14],[13,12]}
Test Paths: i.[1,2,3,4,5,7,4,6,8,9,10,2,11,12,13,12,14]
ii.[1,2,3,4,5,6,8,10,2,11,12,14]
Prime path coverage:
TR={ [12,13,12],[13,12,13],[4,5,7,4],[5,7,4,5],[7,4,5,7],[2,3,4,6,8,10,2],
[3,4,6,8,10,2,3],[4,6,8,10,2,3,4],[6,8,10,2,3,4,6],[8,10,2,3,4,6,8],
[10,2,3,4,6,8,10],[2,3,4,5,6,8,10,2],[2,3,4,6,8,9,10,2],
[3,4,5,6,8,10,2,3],[3,4,6,8,9,10,2,3],[4,5,6,8,10,2,3,4],
[4,6,8,9,10,2,3,4],[5,6,8,10,2,3,4,5],[6,8,9,10,2,3,4,6],
[6,8,10,2,3,4,5,6],[8,9,10,2,3,4,6,8],[8,10,2,3,4,5,6,8],
[9,10,2,3,4,6,8,9],[10,2,3,4,5,6,8,10],[10,2,3,4,6,8,9,10],
[2,3,4,5,6,8,9,10,2],[3,4,5,6,8,9,10,2,3],[4,5,6,8,9,10,2,3,4],
[5,6,8,9,10,2,3,4,5],[6,8,9,10,2,3,4,5,6],[8,9,10,2,3,4,5,6,8],
[9,10,2,3,4,5,6,8,9],[10,2,3,4,5,6,8,9,10],
[1,2,11,12,13],[1,2,11,12,14],[1,2,3,4,5,7],[1,2,3,4,6,8,10],
[1,2,3,4,5,6,8,10],[1,2,3,4,6,8,9,10],[5,7,4,6,8,10,2,3],
[6,8,10,2,3,4,5,7],[7,4,5,6,8,10,2,3],[1,2,3,4,5,6,8,9,10],
[3,4,6,8,10,2,11,12,13],[3,4,6,8,10,2,11,12,14],[5,7,4,6,8,9,10,2,3]
[6,8,9,10,2,3,4,5,7],[7,4,5,6,8,9,10,2,3],[3,4,5,6,8,10,2,11,12,14],
[3,4,5,6,8,10,2,11,12,13],[3,4,6,8,9,10,2,11,12,13],
[3,4,6,8,9,10,2,11,12,14],[5,7,4,6,8,10,2,11,12,13],
[5,7,4,6,8,10,2,11,12,14],[7,4,5,6,8,10,2,11,12,13],
[7,4,5,6,8,10,2,11,12,14],[3,4,5,6,8,9,10,2,11,12,13],
[3,4,5,6,8,9,10,2,11,12,14],[5,7,4,6,8,9,10,2,11,12,13],
[5,7,4,6,8,9,10,2,11,12,14],[7,4,5,6,8,9,10,2,11,12,13],
[7,4,5,6,8,9,10,2,11,12,14]
}
2.According to the printPrimes(), design a test for Prime paths Coverage.
I modified the source code in the book, and the test code as follows:
The test result as follows:
标签:body art 问题 with appear code set ted 用例
原文地址:http://www.cnblogs.com/humeng96/p/6546939.html