Software Testing Homework03:

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Software Testing Homework03:相关的知识,希望对你有一定的参考价值。

1.回答书上63-64printPrimes()问题a-d

a:本题控制流图如下图1所示

为查看方便,利用图2进行答题

技术分享  技术分享                  

                                   图1                         图2

b:

  我们注意到代码第十行有int [] primes = new int [MAXPRIMES]

若在程序中设置MAXPRIMES = 4,那么当运行t1时不会出错误,但是在运行t2时会出现数组越界错。

c:

     设计一个不经过while循环体的测试用例

     t3 = n=10

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=10

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:

技术分享    技术分享

 

以上是关于Software Testing Homework03:的主要内容,如果未能解决你的问题,请参考以下文章

Software Testing Homework 2

Software Testing Homework03:

Software Test HOMEWORK01:

Software Project Managemen(SPM) HOMEWORK01:

Software Engineering homework2

Software Project Management Homework 1--3013218086--