Software Testing Homework03:
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:
???
?
轉載于:https://www.cnblogs.com/humeng96/p/6546939.html
總結
以上是生活随笔為你收集整理的Software Testing Homework03:的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Transient关键字的使用
- 下一篇: 11:数值的整数次方