admin管理员组

文章数量:1606929

软件测试中的错误主要分为三种: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://wwwblogs/hanmo/p/8545730.html

本文标签: 作业测试软件failureError