2018软件测试_Homework 2

作业要求很简单,就是对这两个函数进行分析,考察对于fault、error、failure的理解,具体作答如下:

  • Identify the fault

左侧findLast函数,在for循环中,i>0应改为i>=0,否则不会判断数组第一位;

右侧lastZero函数,若数组不为空且存在0,当前返回结果为数组中0所在的最小下标,即FIRST 0 in x,for循环中的判断条件应改为:

for(int i = x.length-1; i >= 0; i--)
  • If possible, identify a test case that does not execute the fault. (Reachability)

findLast:

test: x=null; y = 3

lastZero:

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

findLast:

test: x=[1, 2]; y = 2

lastZero:

test: x=[0]
  • If possible identify a test case that results in an error, but not a failure.

findLast:

test: x=[1, 2]; y = 3

lastZero:

test: x=[1, 2]

 

posted @ 2018-03-11 21:21  LKFrunning  Views(167)  Comments(0)    收藏  举报