软件测试作业3 — PrintPrimes()
一.Use the following method printPrimes() for questions a–d.
(a) Draw the control flow 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--描述Error
记忆犹新的错误: 上个学期选修了可视化这门课程,最后大作业用d3实现,在使用d3读取csv数据的时候出现了以下Error: 我先是在代码中读取了某csv格式的数据,并且将其存入变量root中,然后对r ...
- 软件测试作业1 — 令我印象最深的BUG
回顾从大一到大三的学习生活,我在学习过程中遇到过许多BUG,刚开始和罗凯老师学习C++时从来没有接触过编程,那时候导致程序不能运行的原因多是语法错误和拼写错误,到了大一下学期,错误多出现在循环与条件跳 ...
- 软件测试作业——WordCount的测试
一.代码提交 1.代码地址:https://gitee.com/zst1978805482/WordCount 2.作业地址:https://edu.cnblogs.com/campus/xnsy/T ...
- 软件测试作业-selenium
一.作业要求 1.安装SeleniumIDE插件. 2.学会使用SeleniumIDE录制脚本和导出脚本. 3.访问网址使用学号登录系统,进入系统后可以看到该同学的git地址. 4.编写Seleniu ...
- 软件测试作业3--Junit、hamcrest、eclemmat的安装和使用
1. how to install junit, hamcrest and eclemma? 首先下载下来Junit和Hamcrest的jar包,然后新建项目的时候将这两个jar包导入到工程里面就 ...
- 软件测试作业三 尝试使用JUnit
写一个判断三角形种类的代码,对其进行测试. 判断三角形代码: package 测试1; public class sjx { public String f(int a,int b,int c) { ...
- 软件测试作业 - fault error failure
给出的题目如下: 我的解答如下: For program 1:1. where i > 0 is the fault , it should be changed to i>= 0 to ...
- 软件测试技术第三次作业——打印质数printPrimes()
作业一.Use the following method printPrimes() for questions a–d. printPrimes: /** ********************* ...
- 软件测试第三次作业——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, ...
随机推荐
- Unity3D中切换场景可能导致材质变暗的问题
Unity版本:5.1.1f1 做公司项目的时候,无意间发现了一个很奇葩的现象:场景A(纯UI,故没有光源)转场到场景B的时候,B中原有的光源似乎失效了,但在Hierarchy窗口中能够看到光源存在, ...
- ThinkPHP 分组,应用,跳转
一.多应用配置技巧 在主入口文件index.php同级目录,新建一个 config.php 写入公共的配置项,然后在前后台各自的配置文件config.php中 $arr = include ...
- easelJS入门、事件、spritesheet
easelJS入门.事件.spritesheet <%@ page language="java" contentType="text/html; charset= ...
- 搭建typescript开发环境最详细的全过程
搭建typescript开发示例https://github.com/Microsoft/TypeScriptSamples typescript案例https://www.tslang.cn/sam ...
- 去除android或者iOS系统默认的一些样式总结
ios系统中元素被触摸时产生的半透明灰色遮罩怎么去掉 iOS用户点击一个链接,会出现一个半透明灰色遮罩, 如果想要禁用,可设置-webkit-tap-highlight-color的alpha值为0, ...
- js精要之函数
数组排序 ,,,,,]; arr.sort(function(a,b){ return a-b; }); console.log(arr); arguments 参数存储对象 function ref ...
- for语句输出图形
一.输出以下图形 ******************************** 用for...for...嵌套循环,内循环控制每一行的个数(即列数),外循环控制行数 class ForDraw { ...
- 最新升级的火狐38.0.6识别ajax调用返回的""空值可能有异常。
自已在调用一段ajax开发中,返回的是空值 string result = string.Empty;return result; 但在页面进行$.ajax调用 时 输出alert(result);应 ...
- C# 6 与 .NET Core 1.0 高级编程 - 39 章 Windows 服务(上)
译文,个人原创,转载请注明出处(C# 6 与 .NET Core 1.0 高级编程 - 39 章 Windows 服务(上)),不对的地方欢迎指出与交流. 章节出自<Professional C ...
- 安卓UDP通信
功能: 实现了单次一发一收: import java.net.*; import java.io.*; public class udpRecv { /* * 创建UDP传输的接收端 * 1.建立ud ...