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 ...
随机推荐
- DNS信息
主机A记录: 描述主机地址记录,在dns域名和ip地址之间建立映射关系语法: owner class ttl A IP_v4_address eg: host1.example.mircrosoft. ...
- JSP/Servlet(一)
JSP/Servlet(一) Web应用和web.xml文件: 一.构建Web应用: 1.在任意目录下创建一个文件夹. 2.在第1步所建的文件夹内建一个WEB-INF文件夹(注意大小写). 3.进 ...
- Bootstrap Paginator分页插件+ajax 实现动态无刷新分页
之前做分页想过做淘宝的那个,但是因为是后台要求不高,就Bootstrap Paginator插件感觉还蛮容易上手,所以就选了它. Bootstrap Paginator分页插件下载地址: Downlo ...
- CAGradientLayer颜色渐变器
使用CAGradientLayer可以实现颜色的渐变, 我们先看下头文件 @interface CAGradientLayer : CALayer @property(nullable, copy) ...
- CodeForces758D
D. Ability To Convert time limit per test:1 second memory limit per test:256 megabytes input:standar ...
- 个人对现在大众对perl的偏见的一些见解
最近我都在一些论坛和交流社区学习,发现很多人对perl有很大的偏见. 以我学习那么久的Perl来说吧,也算是有一些小经验了,所以我总结了大家对perl的偏见的原因,无非就是是下面两个的两个原因: 1. ...
- 在QT中引用Shark Machine Learning library
最近因为项目需要,看了看机器学习方面的东西.Google一番,发现Shark正是朕需要的东西.于是准备按官方文档来使用它了.但是官方文档只有怎么生成静态库,并没有在QT里引用的sample. 废话不多 ...
- css3 过渡和2d变换——回顾
1.transition 语法:transition: property duration timing-function delay; transition-property 设置过渡效果的css ...
- iOS开发常用
http://blog.csdn.net/u013043666/article/details/51353386 1.打电话 第一种 NSString *telNum = model.contact; ...
- UITextField总结
----------------- 监听文字有多长 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:( ...