软件测试第三次作业——习题2.3.7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了软件测试第三次作业——习题2.3.7相关的知识,希望对你有一定的参考价值。

a)

技术分享

b)若MAXPRIMES为2,则t2在primes[numPrimes]=curPrime(即上图节点8)处会发生访问非法内存的错误,因为n=5时质数有2,3,5.但t1不会出错,因为n=3时质数只有2,3.

c)t=(n=1).

d)点覆盖:{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}

边覆盖:{(0,1),(1,2),(1,11),(2,3),(3,4),(3,7),(4,5),(4,6),(5,7),(6,3),(7,8),(8,9),(8,10),(9,10),(10,1),(11,12),(12,13),(13,14),(13,15),(14,13)}

主路径覆盖{(13,14,13)(14,13,14)(14,13,15)(3,4,6,3)(4,6,3,4)(6,3,4,6)(0,1,2,3,4,6)(0,1,11,12,13,14)(0,1,11,12,13,15)(0,1,2,3,7,8,10)(1,2,3,7,8,10,1)(2,3,7,8,10,1,2)(3,7,8,10,1,2,3)(7,8,10,1,2,3,7)(8,10,1,2,3,7,8)(10,1,2,3,7,8,10)(0,1,2,3,7,8,9,10)(1,2,3,7,8,9,10,1)(2,3,7,8,9,10,1,2)(3,7,8,9,10,1,2,3)(4,6,3,7,8,10,1,2)(7,8,9,10,1,2,3,7)(8,9,10,1,2,3,7,8)(9,10,1,2,3,7,8,9)(10,1,2,3,7,8,9,10)(0,1,2,3,4,5,7,8,10)(1,2,3,4,5,7,8,10,1)(2,3,4,5,7,8,10,1,2)(3,4,5,7,8,10,1,2,3)(4,5,7,8,10,1,2,3,4)(4,6,3,7,8,9,10,1,2)(5,7,8,10,1,2,3,4,5)(5,7,8,10,1,2,3,4,6)(6,3,4,5,7,8,10,1,2)(7,8,9,10,1,2,3,4,6)(7,8,10,1,2,3,4,5,7)(8,10,1,2,3,4,5,7,8)(10,1,2,3,4,5,7,8,10)(0,1,2,3,4,5,7,8,9,10)(1,2,3,4,5,7,8,9,10,1)(2,3,4,5,7,8,9,10,1,2)(3,4,5,7,8,9,10,1,2,3)(4,5,7,8,9,10,1,2,3,4)(5,7,8,9,10,1,2,3,4,5)(5,7,8,9,10,1,2,3,4,6)(6,3,4,5,7,8,9,10,1,2)(7,8,9,10,1,2,3,4,5,7)(8,9,10,1,2,3,4,5,7,8)(9,10,1,2,3,4,5,7,8,9)(10,1,2,3,4,5,7,8,9,10)(2,3,7,8,9,10,1,11,12,13,14)(2,3,7,8,9,10,1,11,12,13,15)(4,6,3,7,8,10,1,11,12,13,14)(4,6,3,7,8,10,1,11,12,13,15)(2,3,4,5,7,8,10,1,11,12,13,14)(2,3,4,5,7,8,10,1,11,12,13,15)(4,6,3,7,8,9,10,1,11,12,13,14)(4,6,3,7,8,9,10,1,11,12,13,15)(6,3,4,5,7,8,10,1,11,12,13,14)(6,3,4,5,7,8,10,1,11,12,13,15)(2,3,4,5,7,8,9,10,1,11,12,13,14)(2,3,4,5,7,8,9,10,1,11,12,13,15)(6,3,4,5,7,8,9,10,1,11,12,13,14)(6,3,4,5,7,8,9,10,1,11,12,13,15)}

基于Junit测试:

package test;

import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class testhello {
private hello cal;
	
	// 执行任意一个方法之前都会执行setUp方法
	@Before
	public void setUp(){
		cal = new hello();
	}
	
	// 加了@Test表示该方法是一个单元测试
 	@Test
	public void testPrime(){
 		cal.printPrimes(20);
	}
 	
 	//hamcrest 1.3
}

  结果截图:

技术分享

技术分享

覆盖测试:

技术分享

技术分享

 

以上是关于软件测试第三次作业——习题2.3.7的主要内容,如果未能解决你的问题,请参考以下文章

软件测试第三次作业

第三次作业

第三次作业

第三次作业

第三次作业

第三次作业