码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-03-14 18:53:23      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:com   pac   private   void   highlight   ack   max   执行   img   

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

标签:com   pac   private   void   highlight   ack   max   执行   img   

原文地址:http://www.cnblogs.com/3014218068sht/p/6548994.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!