1. 程式人生 > >2018軟件測試_Homework 2

2018軟件測試_Homework 2

class height OS HA 不為 nbsp 判斷 com eight

技術分享圖片

作業要求很簡單,就是對這兩個函數進行分析,考察對於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]

2018軟件測試_Homework 2