【软件测试第二次作业】fault , error 和 failure

软件测试中的错误主要分为三种:Failure, Error 和 Fault

  下面就分析一下它们的不同:

  Fault的定义:可能导致 系统或功能失效的异常条件(Abnormal condition that can cause an element or an item to fail.),可译为“故障”
  
  Error的定义:计算、观察或测量 值或条件,与真实、规定或理论上正确的 值或条件之间的差异( Discrepancy between a computed, observed or measured value or condition and the true, specified, or theoretically correct value or condition.),可译为“错误”。Error是能够导致系统出现Failure的系统内部状态
 

  Failure的定义:当一个系统不能执行所要求的功能时,即为Failure,可译为“失效”。(Termination of the ability of an element or an item to perform a function as required.)

  
  三者关系分析:
  • 由于人类试图通过上述3个基本术语来覆盖所有现实中的失效场景,所以就有“Fault -> Error -> Failure”。即,故障发生了,会导致错误,错误有可能造成系统功能的减弱或丧失
  • 当Fault是另外一个组件/系统的失效时,则有Failure (Fault) -> Error -> Failure;当将Fault说成是某组件状态Error时,则有Error (Fault) -> Error -> Failure
  • 事实上,这是一种递归循环的关系,递归关系要成立必须有一个明确的结束条件,这个条件就是要找出Root Cause,否则将无法完成一个失效分析。     

 

  举例

  病人告诉医生自己的各种症状,身体没有健康地工作 – Failures 

  医生想找出疾病的根源,如病毒 – Fault 

  病人身体状态异常,比如血压较高,心跳不规律等 – Errors

作业内容: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.

【代码一】

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

Identify the fault.

  

   it should be i>=0

If possible, identify a test case that does not execute the fault. (Reachability)

  x = [ ]  y=1 

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

  x = [1,2,3]  y=3 expected = 2

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

   x = [1,2,3]  y=4 expected = -1

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

Identify the fault.

  

  it should be i< x.length - 1

If possible, identify a test case that does not execute the fault. (Reachability)

  x = [ ] 

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

  x = [1,0,1]   expected = 1

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

   x = [1,2,3]  expected = -1

 

转载于:https://www.cnblogs.com/hanmo/p/8545730.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值