一.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. js原生设计模式——3简单工厂模式\js面向对象编程实例

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  2. redhat6.4下安装Oracle11g

    一.在Root用户下执行以下步骤: 1)修改用户的SHELL的限制,修改/etc/security/limits.conf文件 *               soft    nproc  2047 ...

  3. mongo db 启动停止

    1.下载压缩包,解压,bin目录放在path中: 2.cmd中输入mongod --dbpath d:\xx\yy\data 启动了 3.如果错误关闭,到d:\xx\yy\data中删除.lock文件 ...

  4. CardboardSDK-iOS 源码简单分析

    该项目地址: 地址 克隆地址为 https://github.com/rsanchezsaez/CardboardSDK-iOS.git 目前如果想在iOS设备上实现双目VR的功能,Google 已经 ...

  5. Omi原理-Hello Omi

    Hello Omi Omi框架的每个组件都继承自Omi.Component,本篇会去完成Omi的Component的基本锥形,让其能够渲染第一个组件. omi.js实现 var Omi = {}; O ...

  6. node Express安装与使用(一)

    首先放上官网地址 http://www.expressjs.com.cn/ 学会查阅官方手册,它是最好的资料. 1.Express安装 首先确定你已经安装了 Node.js,然后去你创建的项目目录下( ...

  7. Odoo安装

    打开终端机0. sudo passwd root #设定超级使用者密码1. sudo apt-get update #更新软件源2. sudo apt-get dist-upgrade #更新软件包, ...

  8. SpringMVC简版教程、部分功能

    注:本文只用注解来实现 前言 SpringMVC各种流程图流程图(其他的各种流程图) jsp.xml.action彼此之间的关系,都如何使用 spring-mvc.xml如何配置,放在哪里? acti ...

  9. php小测试,难点与分享

    B/S(网页程序) 网页结构,依托游览器 C/S(客户端程序) 单引号和双引号包含字符串的区别: 双引号里面可以解析变量,比如: $a=555; echo "你好{$a}"; 输出 ...

  10. CSS3高级选择器

    CSS3中添加了一些新的选择器 与之前的不同 这些选择器有些类似于jquery的选择器 能够让我们更高的操作DOM 废话不多说 为了更直观的了解 我们以这段为实例 来进行操作 <!DOCTYPE ...