软件测试作业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, ...
随机推荐
- Redhat6.4下配置本地yum
一.准备工作1. Linux安装盘插入光驱 2. 挂载光驱 [root@localhost ~]# mount /dev/cdrom /mnt/ mount: block device /dev/s ...
- bootstrap 树
http://jsfiddle.net/jhfrench/GpdgF/ 把原文的i标签中的图标显示出来: 源码: <div class="tree well"> < ...
- 比AutoMapper轻量快速简洁的实体映射库YeaJur.Mapper
之前在做实体深拷贝时一直使用的AutoMapper,但是总是觉得其写法比繁琐,效率也不算很高,自己写了一个轻量级的实体拷贝库YeaJur.Mapper,和AutoMapper 测试对比如下 PK项 Y ...
- java算法 蓝桥杯 乘法运算
问题描述 编制一个乘法运算的程序. 从键盘读入2个100以内的正整数,进行乘法运算并以竖式输出. 输入格式 输入只有一行,是两个用空格隔开的数字,均在1~99之间(含1和99). 输出格式 输出为4行 ...
- 比特(bit)、字,字节(B)存储单位之间的关系+其与操作系统位数的关系+不同编译器编译方式下数据类型的表示范围
1.在表示网络传输速度中与表示存储单位的不同: 表示存储单位时:1kB=1024B,但在网络中表示传输速度是1KB=1000B 2.下面介绍表示存储单位时的关系及其与操作系统位数的关系: 1B=8bi ...
- node Express安装与使用(一)
首先放上官网地址 http://www.expressjs.com.cn/ 学会查阅官方手册,它是最好的资料. 1.Express安装 首先确定你已经安装了 Node.js,然后去你创建的项目目录下( ...
- 对Node.JS的事件轮询(Event Loop)的理解
title: Node.JS的事件轮询(event loop)的理解 categories: 理解 tags: Node JS 机制 当我们知道I/O操作和创建新线程的开销是巨大的! 网站延迟的开销 ...
- block和delegate的区别
代理 可读性高 大部分可以属性 block 写的代码少 一般作为参数通知 占用资源 无论是block还是delegate模式本质上都是回调,使用block,其优点是回调的block代码块直 ...
- Python 日志模块实例
python 打印对象的所有属性值: def prn_obj(obj): print '\n'.join(['%s:%s' % item for item in obj.__dict__.it ...
- 【m元素集合的n个元素子集】
/* m元素集合的n个元素子集 说明: 假设有个集合拥有m个元素,任意的从集合中取出n个元素,则这n个元素所形成的可能子集有那些? 解法: 假设有5个元素的集点,取出3个元素的可能子集如下: {1 2 ...