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 ...
随机推荐
- jq操作radio,设置选中、获取选中值
<label><inputtype="radio"name="sex"value="1">男</label&g ...
- 用Redis作为Mysql数据库的缓存
看到一篇不错的博文,记录下: http://blog.csdn.net/qtyl1988/article/details/39553339 http://blog.csdn.net/qtyl1988/ ...
- Nginx之RTMP
1. RTMP协议介绍 RTMP(Real Time Messaging Protocol)实时消息传送协议是Adobe Systems公司为Flash播放器和服务器之间音频.视频和数据传输开发的私有 ...
- HTML5中将video设置为背景的方法
主要用到了video标签,css样式,原理是先将video标签利用position:fixed;使video标签脱离文档流,在将他的z-index设置为最低的,比如-9999.再插入的内容自然就覆盖在 ...
- HDU5873
Football Games Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- [笔记]A Practical Guide to Support Vector Classication
<A Practical Guide to Support Vector Classication>是一篇libSVM使用入门教程以及一些实用技巧. 1. Basic Kernels: ( ...
- WinForm 文件操作
文件及文件夹操作 C/S:WinForm可以操作客户端文件 Client ServerB/S:浏览器服务 Brower Server 命名空间:using system .IO; 1. File类:文 ...
- C语言高效位操作
思考: 1. 如何将一个数据中的多个不连续位清位? 1. 如何将一个数据中的多个不连续位置位? 1. 如何反转一个数据中的多个不连续位(1->0, 0->1)? 基础知识:C 语言位操作 ...
- 学习计划——巩固基础+进阶练习
时间:2016/3/23---24 内容:如何用CSS进行网页布局 课程复习 目标:完成一个demo+完成一篇学习心得博客 时间:2016/3/25---26 内容:网页布局基础 课程复习 目标: ...
- PHP接入芝麻信用续。
前面,做好了,PHP查询芝麻信用. 客户又要求说,芝麻官方,发来邮件,还需要提交网站的数据给芝麻, 就是说接入芝麻SDK,还有一步,就是数据反馈. 大概芝麻分就是根据这些反馈的数据来计算的吧. 不多说 ...