一.Use the following method printPrimes() for questions a–d.

(a) Draw the control ow graph for the printPrimes() method.

(b) Considertestcasest1=(n=3)andt2=(n=5).Although these tourthe same prime paths in printPrimes(), they do not necessarily find the same faults.Designasimplefaultthat t2 would bemorelikelytodiscover than t1 would.

 

答:将MAXPRIMES设置为4时,t2会发生数组越界错误,但t1不会发生错误。

(c) For printPrimes(), find a test case such that the corresponding test path visits the edge that connects the beginning of the while statement to the for statement without going through the body of the while loop.

答:当n=1时,会通过numPrimes>=直接从上图的2节点跳转到12节点,不经过while循环体内部。

(d) Enumerate the test requirements for node coverage, edge coverage, and prime path coverage for the graph for printPrimes().

答:

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

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

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

二.基于Junit及Eclemma(jacoco)实现一个主路径覆盖的测试。

测试代码:

 import static org.junit.Assert.*;

 import org.junit.Before;
import org.junit.Test; public class PrintPrimesTest { private PrintPrimes pptest; @Before
public void setUp() throws Exception {
pptest = new PrintPrimes();
} @Test
public void testPrintPrimes() {
pptest.printPrimes(5); }
}

测试结果:

使用EclEmma 进行覆盖测试:

软件测试作业3 — PrintPrimes()的更多相关文章

  1. 软件测试作业1--描述Error

    记忆犹新的错误: 上个学期选修了可视化这门课程,最后大作业用d3实现,在使用d3读取csv数据的时候出现了以下Error: 我先是在代码中读取了某csv格式的数据,并且将其存入变量root中,然后对r ...

  2. 软件测试作业1 — 令我印象最深的BUG

    回顾从大一到大三的学习生活,我在学习过程中遇到过许多BUG,刚开始和罗凯老师学习C++时从来没有接触过编程,那时候导致程序不能运行的原因多是语法错误和拼写错误,到了大一下学期,错误多出现在循环与条件跳 ...

  3. 软件测试作业——WordCount的测试

    一.代码提交 1.代码地址:https://gitee.com/zst1978805482/WordCount 2.作业地址:https://edu.cnblogs.com/campus/xnsy/T ...

  4. 软件测试作业-selenium

    一.作业要求 1.安装SeleniumIDE插件. 2.学会使用SeleniumIDE录制脚本和导出脚本. 3.访问网址使用学号登录系统,进入系统后可以看到该同学的git地址. 4.编写Seleniu ...

  5. 软件测试作业3--Junit、hamcrest、eclemmat的安装和使用

    1.   how to install junit, hamcrest and eclemma? 首先下载下来Junit和Hamcrest的jar包,然后新建项目的时候将这两个jar包导入到工程里面就 ...

  6. 软件测试作业三 尝试使用JUnit

    写一个判断三角形种类的代码,对其进行测试. 判断三角形代码: package 测试1; public class sjx { public String f(int a,int b,int c) { ...

  7. 软件测试作业 - fault error failure

    给出的题目如下: 我的解答如下: For program 1:1. where i > 0 is the fault , it should be changed to i>= 0 to ...

  8. 软件测试技术第三次作业——打印质数printPrimes()

    作业一.Use the following method printPrimes() for questions a–d. printPrimes: /** ********************* ...

  9. 软件测试第三次作业——7.使用下面方法printPrimes()完成后面的问题(a)~(f)

    (a)控制流图如下: (b)令MAXPRIMES=4,会出现越界错误. (c)令n=1,不会经过while循环体. (d)节点覆盖:{1,2,3,4,5,6,7,8,9,10,11,12,13,14, ...

随机推荐

  1. GCD教程(二):多核心的性能

    接上一篇,原帖地址:http://www.dreamingwish.com/dream-2012/of-of-of-performance-of-of-of-of-of-of-of-gcd-intro ...

  2. 使用Intent创建Tab页面

    前面已经介绍了如何使用TabActivity来创建Activity布局,前面添加Tab页面使用了TabHost.TabSpec如下方法. setContent(int viewId):直接将指定Vie ...

  3. 第二部分 条件控制执行语句、循环语句、switch语句、跳转语句和其它语句

    条件控制执行语句: if语句 if....else....语句 循环语句: while语句 do....while语句 for语句 switch语句: 跳转语句: break; continue; r ...

  4. Flex移动皮肤开发(三)

    范例文件 mobile-skinning-part3 在关于创建Flex移动皮肤系列文章的第二部分里,我们讨论了屏幕密度(DPI)对组件皮肤以及移动应用布局所带来的影响. 我还展示了如何使用缩放应用, ...

  5. HMX-Server C++ 分步式服务器大版本更新了(有源码)

    原文地址:http://www.cnblogs.com/hellohuang/p/6294763.html # HMX-ServerHMX-Server分步式服务器框架,主要分为网关.登录.世界.场景 ...

  6. android:在ViewPager中使用Button

    最近在项目用用到ViewPager ,其中页面包含有Button,因为之前也有使用个ViewPager ,所以这个也照搬之前的方式,测试后发现点击button无法执行,这个button是在第一页面的默 ...

  7. webSocket错误收集

    关于 使用WebSocket报如下错误, Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': already in ...

  8. iOS核心笔记—MapKit框架-基础

    1.MapKit框架简介: ✨了解:MapKit框架使用须知:①.MapKit框架中所有的数据类型的前缀都是MK:②.需要导入#import <MapKit/MapKit.h>头文件:③. ...

  9. 循环语句——for语句

    一.for语句结构:for (初始化表达式; 循环条件表达式 ;循环后的操作表达式 ) { 执行语句: } 循环条件表达式,必须是true或false 示例: class ForDemo { publ ...

  10. linq左连接查询加上into后怎么查询右表是否为空

    //判断右表是否为空并为映射表进行赋值标志var query=from q in product join m in favProduct on q.Name equals m.Name into t ...