ST HW2 fault & error & failure
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的更多相关文章
- 软件测试中的fault,error,failure
问题:给定两段代码,设计fault,error,failure的测试用例. fault:即引起错误的原因,类似病因. error:类似疾病引起的内部结果. failure:类似疾病引起的症状. 代码1 ...
- 结对编程2—Fault&Error&Failure
学习进度表 点滴成就 学习时间 新编写代码行数 博客量(篇) 学到知识点 第一周 8 0 0 了解软件工程 第二周 10 0 1 博文一篇 第三周 15 0 2 选择项目.调查问卷 第四周 20 80 ...
- 结对编程--fault,error,failure的程序设计
一.结对编程内容: 1.不能触发Fault. 2.触发Fault,但是不触发Error. 3.触发Error,但不触发Failure. 二.结对编程人员 1.周浩,周宗耀 2.结对截图: 三.结对项目 ...
- 结对项目——fault,error,failure的程序设计
一.结对编程内容: 1.不能触发Fault. 2.触发Fault,但是不触发Error. 3.触发Error,但不触发Failure. 二.结对编程人员 1.周宗耀.周浩: 2.结对截图: 三.结对项 ...
- 软件测试作业 - fault error failure
给出的题目如下: 我的解答如下: For program 1:1. where i > 0 is the fault , it should be changed to i>= 0 to ...
- 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 ...
- 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 ...
- [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 ...
- 安装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 ...
随机推荐
- pyspark 内容介绍(一)
pyspark 包介绍 子包 pyspark.sql module pyspark.streaming module pyspark.ml package pyspark.mllib package ...
- 001.MVC基本概述
MVC的基本概念 一.NET平台下开发web应用程序的方案(方法) 方案A:ASP.NET webForm1.web窗体:臃肿(胖)性能低 优点:有很多的web控件可以使用,能够方便的和服务端交互(数 ...
- 常用的JQ函数
/// <reference path="jquery-1.8.0.min.js"> /* * DIV或元素居中 * @return */ jQuery.fn.mCen ...
- win10下VS2015局域网调试配置
一.前言 换win10页挺久了一直没有使用 IISExpress 的局域网功能,今天一使用才发现 win10 比起 win7 下配置多了许多坑. 二.配置步骤 首先我们先来拿到本机 ip 地址 打开命 ...
- MySQL插入数据中文乱码问题的解决
一.使用语句 show variables like 'character%'; 来查看当前数据库的相关编码集. 1.启动cmd,登录mysql ①cd C:\Program Files\MySQL\ ...
- 浅谈stream数据流
汴水流,泗水流,流到瓜州古渡头, 吴山点点愁. 我们知道水是源源不断的, 抽刀断水水更流, 斩不断, 理还乱, 是水流.(技术贴, 本文权当读者没学过古诗). 在一些语言里, 我们的前辈把数据 ...
- headfirst设计模式(2)—观察者模式
定义 观察者模式(有时又被称为发布(publish)-订阅(Subscribe)模式,在此种模式中,一个目标物件管理所有相依于它的观察者物件,并且在它本身的状态改变时主动发出通知.这通常透过呼叫各观察 ...
- block之---内存管理
首先简单说下MRC和ARC MRC: 手动管理内存,需要自己去释放内存, 如果对象的引用计数器为0时对象就会被释放. 属性修饰策略:assign, retain, copy ARC: ARC是编译器特 ...
- VS error 全集(error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'char *' to 'LPCTSTR'的解决方法)
我用的是VS2005,在编译MFC时遇到了如下错误: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'char ...
- OSS项目进度(2.19)
前两周先后完成了OSS.Common ,OSS.Http ,OSS.Social 项目的.net standard支持,再次开始进入框架本身的开发,今天进度情况: 一.OSS.Social 完成摇一摇 ...