软件测试:2.Two Faulty Programs
Questions:
1.Identify the fault;
2.If possible, identify a test case that does not execute the fault; (Reachability)
3.If possible, identify a test case that executes the fault, but does not result in an error state;
4.If possible, identify a test case that result in an error, but not a failure.
Answers:
1.左侧函数fault位于第7行的for循环里的循环条件,循环结束的判断条件有误,对应代码应为
for(int i=x.length-1; i>=0; i--)
右侧函数fault位于第7行的for循环里的循环条件,循环遍历数组的方向有误,找到最后一个0的函数,数组应该从后往前遍历,对应代码应为
for(int i=x.length-1; i>=0; i--)
2.Identify a test case that does not execute the fault.
左侧函数:
test: x=[]; y=3
右侧函数:
test: x=[]
3.Identify a test case that executes the fault, but does not result in an error state.
左侧函数:
test: x=[2,3,5]; y=3
右侧函数:
test: x=[0]
4.Identify a test case that result in an error, but not a failure.
左侧函数:
test: x=[2,3,5]; y=1
右侧函数:
test: x=[1,0,1]
如果不足,欢迎指教,感激不尽