軟體測試homework3

來源:互聯網
上載者:User

標籤:

一、對一個方法進行測試

private static  void printPrimes(int n){        int curPrime;        int numPrimes;        boolean isPrime;        int [] primes = new int [43];        primes[0]=2;        numPrimes = 1;        curPrime = 2;        while ( numPrimes < n)        {            curPrime ++ ;            isPrime = true;            for ( int i = 0 ; i <= numPrimes-1 ;i++){                if (isDivisible(primes[i],curPrime))                {                    isPrime = false;                    break ;                }            }            if (isPrime){                primes[numPrimes] = curPrime ;                numPrimes ++ ;                            }        }                for (int i = 0 ; i <= numPrimes -1 ; i++ )        {            System.out.println("Prime: " + primes[i]);        }            }

1)畫出此方法的控制流程圖

2)T1 : n = 3 ;T2 : n = 5;

設計一個 Fault 使T2 能發現,T1不能發現:

答:

將  if ( isDivisible(primes[i],curPrime) 修改 為  if ( isDivisible(primes[0],curPrime) 

3)設計一個測試案例不經過While的body

答:

n <= 1 即可

4)枚舉TR 對於 NC ,EC ,PPC 

TR :

i)NC:{1,2,3,4,5,6,7,8,9,10,11,12,13}

ii)EC:{(1,2),(2,3),(2,10),(3,4),(4,5),(4,8),(5,6),(5,7),(6,8),(7,4),(8,2),(8,9),

(9,2),(10,11),(11,12),(11,13),(12,11)}

iii)PPC:一共51條

A.[11,12,11] , [12,11,12]點11,12組成的環可以寫出2條路徑

B.點4,5,7 組成的環可以寫出3條路徑

C.點2,3,4,8組成的環可以寫出4條路徑

D.點2,3,4,8,9組成的環可以寫出5條路徑

E.點2,3,4,5,6,8組成的環可以寫出6條路徑

F.點2,3,4,5,6,8,9組成的環可以寫出7條路徑

G.點1出發的有5條:[1,2,10,11,13],[1,2,10,11,12],[1,2,3,4,5,7],[1,2,3,4,8,9],[1,2,3,4,5,6,8,9]

H.點3出發的有9條:[3,4,5,7],[3,4,8,2,10,11,12],[3,4,8,2,10,11,13],[3,4,8,9,2,10,11,12],[3,4,8,9,2,10,11,13],

[3,4,5,6,8,2,10,11,12],[3,4,5,6,8,2,10,11,13],[3,4,5,6,8,9,2,10,11,12],[3,4,5,6,8,9,2,10,11,13]

I.點5出發的有4條:[5,7,4,8,2,10,11,12],[5,7,4,8,2,10,11,13],[5,7,4,8,9,2,10,11,12],[5,7,4,8,9,2,10,11,13]

J.點7出發的有4條:[7,4,5,6,8,2,10,11,12],[7,4,5,6,8,2,10,11,13],[7,4,5,6,8,9,2,10,11,12],[7,4,5,6,8,9,2,10,11,13]

K.點8出發的有2條:[8,2,3,4,5,7],[8,2,3,4,5,6]

 

軟體測試homework3

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.