Software Testing

3014218128 牛菲菲

Below are two faulty programs. Each includes a test case that results in failure.Answer the following questions (in the next slide) about each program.

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

answer:

1) Identify the fault.

Fault: for (int i=x.length-1; i > 0; i--)

i should end with 0, but not with 1. The right should be" i>=0 "

Error: i is 1, not 0, on the last iteration
Failure: return the wrong result -1
2) If possible, identify a test case that does not execute the fault. (Reachability)

test: x = NULL, y=2

In this case, the fault isn't executed.

3) If possible, identify a test case that executes the fault, but does not result in an error state.

test: x=[3, 5, 2]; y=2

expected = 2, result is 2

In this case, it executes the fault but does not result in an error state.

4) If possible identify a test case that results in an error, but not a failure.

test: x=[3, 5, 2]; y=1

expected = -1, result is -1

In this case, it results in an error but not a failure.

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

answer:

1) Identify the fault.

Fault: for (int i = 0; i < x.length; i++)

  It will return on the first iteration while it should continue iteration.

Failure: expected =2, result = 0
2) If possible, identify a test case that does not execute the
fault. (Reachability)

x=NULL

3) If possible, identify a test case that executes the fault, but
does not result in an error state.

test: x=[1, 2, 3]

4) If possible identify a test case that results in an error, but
not a failure.

test: x=[1, 0, 2].

ST HW2 fault & error & failure的更多相关文章

  1. 软件测试中的fault,error,failure

    问题:给定两段代码,设计fault,error,failure的测试用例. fault:即引起错误的原因,类似病因. error:类似疾病引起的内部结果. failure:类似疾病引起的症状. 代码1 ...

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

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

  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. 软件测试作业 - fault error failure

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

  6. 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 ...

  7. Error: failure: repodata/repomd.xml from fedora: [Errno 256] No more mirrors to try.

    记录一个小问题,重新买的linux换yum源的时候一直提示: Error: failure: repodata/repomd.xml ] No more mirrors to try. 一直说那个XM ...

  8. [linux]Error: failure: repodata/repomd.xml from fedora: [Errno 256] No more mirrors to try.

    在使用fedora17 系统的yum源的时候出现了例如以下错误: Error: failure: repodata/repomd.xml from fedora: [Errno 256] No mor ...

  9. 安装zabbix-agent报错 Error: failure: repodata/primary.xml.gz from zabbix: [Errno 256] No more mirrors to try.

    安装zabbix-agent报错 yum install -y zabbix-agent Loaded plugins: fastestmirror, refresh-packagekit, secu ...

随机推荐

  1. 《微信小程序七日谈》- 第六天:小程序devtool隐藏的秘密

    <微信小程序七日谈>系列文章: 第一天:人生若只如初见: 第二天:你可能要抛弃原来的响应式开发思维: 第三天:玩转Page组件的生命周期: 第四天:页面路径最多五层?导航可以这么玩: 第五 ...

  2. 大大维的贪吃蛇v1

    虽然本人一直是个免费的游戏测试员(/手动滑稽),但一直有着一个游戏架构师的梦想.正如马爸爸所说,梦想还是要有的,万一实现了呢? 这些天放寒假,有些空闲时间,就想着做一个简单的游戏机.能达到小时候十几块 ...

  3. 基於tiny4412的Linux內核移植 --- 实例学习中断背后的知识(1)

    作者:彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台 tiny4412 ADK Linux-4.9 概述 前面几篇博文列举了在有设备树的时候,gpio中断的 ...

  4. 多线程方式实现Socket通信

    一.首先,介绍下两类传输协议:TCP:UDP TCP是Tranfer Control Protocol的 简称,是一种面向连接的保证可靠传输的协议.通过TCP协议传输,得到的是一个顺序的无差错的数据流 ...

  5. Java IO流学习总结三:缓冲流-BufferedInputStream、BufferedOutputStream

    Java IO流学习总结三:缓冲流-BufferedInputStream.BufferedOutputStream 转载请标明出处:http://blog.csdn.net/zhaoyanjun6/ ...

  6. Git 和 GitHub 使用

    Git和GitHub的使用 Git是一款免费.开源的分布式版本控制系统. GitHub托管远程仓库,并提供一个web界面. 有2种协议支持从本地push代码到远程仓库. 一种是http,需要输入用户名 ...

  7. 【m元素集合的n个元素子集】

    /* m元素集合的n个元素子集 说明: 假设有个集合拥有m个元素,任意的从集合中取出n个元素,则这n个元素所形成的可能子集有那些? 解法: 假设有5个元素的集点,取出3个元素的可能子集如下: {1 2 ...

  8. iOS Foundation框架 -1.常用结构体的用法和输出

    1.安装Xcode工具后会自带开发中常用的框架,存放的地址路径是: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.plat ...

  9. (转)JAVA的整型与字符串相互转换

    JAVA的整型与字符串相互转换1如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Integer.parseInt([String]); 或         ...

  10. IOS任务管理之GCD使用

    前言: 前天学了IOS的NSOperation基本使用,我们得知NSOperation也是基于IOS GCD(Grand Central Dispatch)实现,其实在做IOS开发中GCD已经基本上能 ...