软件测试 图覆盖,软件测试(四)——图覆盖
圖覆蓋
1. 綜述
圖覆蓋
2. 練習(xí)題
已知程序:
/*******************************************************
* Finds and prints n prime integers
* Jeff Offutt, Spring 2003
******************************************************/
public static void printPrimes (intn)
{int curPrime; //Value currently considered for primeness
int numPrimes; //Number of primes found so far.
boolean isPrime; //Is curPrime prime?
int [] primes = new int [MAXPRIMES]; //The list of prime numbers.//Initialize 2 into the list of primes.
primes [0] = 2;
numPrimes= 1;
curPrime= 2;while (numPrimes
{
curPrime++; //next number to consider ...
isPrime = true;for (int i = 0; i <= numPrimes-1; i++)
{//for each previous prime.
if(isDivisable(primes[i],curPrime))
{//Found a divisor, curPrime is not prime.
isPrime = false;break; //out of loop through primes.
}
}if(isPrime)
{//save it!
primes[numPrimes] =curPrime;
numPrimes++;
}
}//End while//Print all the primes out.
for (int i = 0; i <= numPrimes-1; i++)
{
System.out.println ("Prime:" +primes[i]);
}
}//end printPrimes
(a). printPrimes方法的控制流圖為:
(b). 對(duì)于測(cè)試用例t1=(n=3)和t2=(n=5),MAXPRIMES = 4時(shí),t1不能檢查出錯(cuò)誤,而t2則會(huì)發(fā)生數(shù)組越界錯(cuò)。
(c). 對(duì)于測(cè)試用例t3=(n=1),測(cè)試路徑不經(jīng)過(guò)while的循環(huán)體。
(d). 針對(duì)printPrimes()的圖列舉每個(gè)節(jié)點(diǎn)覆蓋、邊覆蓋和主路徑覆蓋的測(cè)試需求。
節(jié)點(diǎn)覆蓋:TR={1,2,3,4,5,6,7,8,9,10,11,12,13,14}
邊覆蓋:TR={(1,2), (2,3), (2,10), (3,4), (4,5), (5,6), (5,8), (6,5), (6,7), (7,8), (8,2), (9,2), (10,11), (11,12), (11,14), (12,13), (13,11)}
主路徑覆蓋:TR={
(1,2,3,4,5,6,7),
(1,2,3,4,5,6,8,9,10,11),
(1,2,3,4,5,6,8,9,11),
(1,2,3,4,5,9,10,11),
(1,2,3,4,5,9,11),
(1,2,12,13,14,15),
(1,2,12,16),
(2,3,4,5,6,8,9,10,11,2),
(2,3,4,5,6,8,9,11,2),
(2,3,4,5,9,10,11,2),
(2,3,4,5,9,11,2),
(3,4,5,6,8,9,10,11,2,12,13,14,15),
(3,4,5,6,8,9,11,2,12,13,14,15),
(3,4,5,6,8,9,10,11,2,12,13,16),
(3,4,5,6,8,9,11,2,12,13,16),
(3,4,5,9,10,11,2,12,13,14,15),
(3,4,5,9,11,2,12,13,14,15),
(3,4,5,9,10,11,2,12,13,16),
(3,4,5,9,11,2,12,13,16),
(5,6,7,5),
(6,7,5,9,10,11,2,12,13,14,15),
(6,7,5,9,11,2,12,13,14,15),
(6,7,5,9,10,11,2,12,13,16),
(6,7,5,9,11,2,12,13,16),
(13,14,15,13),
(14,15,13,16)
}
總結(jié)
以上是生活随笔為你收集整理的软件测试 图覆盖,软件测试(四)——图覆盖的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 计算机模拟多孔碳,多孔碳材料分子设计的三
- 下一篇: 模拟计算机有声,小年糕有声影集软件电脑版