问题:给定两段代码,设计fault,error,failure的测试用例。

fault:即引起错误的原因,类似病因。

error:类似疾病引起的内部结果。

failure:类似疾病引起的症状。

代码1:

public int findLast (int[] x, int y) {
//Effects: If x==null throw NullPointerException
// else return the index of the last element
// in x that equals y.
// If no such element exists, return -1
for (int i=x.length-1; i > 0; i--)
{
if (x[i] == y)
{
return i;
}
}
return -1;
}
// test: x=[2, 3, 5]; y = 2
// Expected = 0

fault:少了i=0的情况。

case1(不执行fault):x为null。

case2(执行fault但不引起error):x为单元素数组{1},y为不为1的数4.没有执行循环体返回-1.

case3(引起error但不引起failure):x为{2,4,6},y为不为x中首元素的数4.执行了循环体但是没有引起错误结果。

代码2:

public static int lastZero (int[] x) {
//Effects: if x==null throw NullPointerException
// else return the index of the LAST 0 in x.
// Return -1 if 0 does not occur in x
for (int i = 0; i < x.length; i++)
{
if (x[i] == 0)
{
return i;
}
} return -1;
}
// test: x=[0, 1, 0]
// Expected = 2

fault:应该从后往前遍历而不是从前往后。

case1(不执行fault):没有,一定会执行for循环中的判断语句。

case2(执行fault但不引起error):x为null。没有执行循环体,返回-1.

case3(引起error但不引起failure):x为{2,4,6},与y对应的元素只能有一个。y为4.执行了循环体但是没有引起错误结果。

软件测试中的fault,error,failure的更多相关文章

  1. 结对编程2—Fault&Error&Failure

    学习进度表 点滴成就 学习时间 新编写代码行数 博客量(篇) 学到知识点 第一周 8 0 0 了解软件工程 第二周 10 0 1 博文一篇 第三周 15 0 2 选择项目.调查问卷 第四周 20 80 ...

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

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

  3. 结对编程--fault,error,failure的程序设计

    一.结对编程内容: 1.不能触发Fault. 2.触发Fault,但是不触发Error. 3.触发Error,但不触发Failure. 二.结对编程人员 1.周浩,周宗耀 2.结对截图: 三.结对项目 ...

  4. 结对项目——fault,error,failure的程序设计

    一.结对编程内容: 1.不能触发Fault. 2.触发Fault,但是不触发Error. 3.触发Error,但不触发Failure. 二.结对编程人员 1.周宗耀.周浩: 2.结对截图: 三.结对项 ...

  5. ST HW2 fault & error & failure

    Software Testing 3014218128 牛菲菲 Below are two faulty programs. Each includes a test case that result ...

  6. 统计分析中Type I Error与Type II Error的区别

    统计分析中Type I Error与Type II Error的区别 在统计分析中,经常提到Type I Error和Type II Error.他们的基本概念是什么?有什么区别? 下面的表格显示 b ...

  7. NDK配置debug环境时:Error:FAILURE: Build failed with an exception

    Error:FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:ex ...

  8. 软件测试中LoadRunner函数中的几个陷阱

    软件测试 中 LoadRunner 函数中的几个陷阱 1.atof 在 loadrunner 中如果直接用 float f; f=atof("123.00"); lr _outpu ...

  9. mysql安装过程中出现错误ERROR 1820 (HY000): You must SET PASSWORD before executing this statement解决

    mysql安装过程中出现错误ERROR 1820 (HY000): You must SET PASSWORD before executing this statement解决   最近新装好的my ...

随机推荐

  1. 杭电 1013 Digital Roots

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1013 反思:思路很简单,但是注意各位数加起来等于10的情况以及输入0的时候结束程序该怎么去表达 #in ...

  2. 02--C编程细节整理(一)

    用C语言比较多,这篇是平时攒下的.有些内容在工作后可能会很常见,但是不用容易忘,所以就写篇博客吧. 1.        printf的用法 %*可以用来跳过字符,可以用于未知缩进.像下面一样. for ...

  3. Difference between == and ===

    In swift 3 and above === (or !==) Checks if the values are identical (both point to the same memory ...

  4. Ikki's Story IV - Panda's Trick POJ - 3207_dfs跑2-SAT

    Code: #include<cstdio> #include<algorithm> #include<vector> using namespace std; c ...

  5. 路飞学城Python-Day115

    个人博客搭建 from django.db import models from django.contrib.auth.models import User, AbstractUser # Crea ...

  6. AM335X用RGB888连接LCD如何以16位色彩模式显示图片

    在AM335x中,在连接显示屏的时候,存在一个问题.这个在am335x Sillicon Errata已经提到过 在RGB888模式中   而对于RGB565模式的硬件连接 不难看出,这个RGB是反的 ...

  7. select的option触发事件

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

  8. js判断当前移动设备平台

    //js判断当前移动设备平台 var isiOs = false; var isAndroid = false; var isWindowsPhone = false; if(/(iPhone|iPa ...

  9. django与mysql实现简单的增删查改

    模型定义 from django.db import models class Grades(models.Model): g_name = models.CharField(max_length=2 ...

  10. 洛谷—— P1126 机器人搬重物

    https://www.luogu.org/problem/show?pid=1126 题目描述 机器人移动学会(RMI)现在正尝试用机器人搬运物品.机器人的形状是一个直径1.6米的球.在试验阶段,机 ...