2016 Tianjin University Software Testing (homework2)

Question one:Identify the fault.
the answer:
the first function :The for-loop misses the 0 index,so that should be -- for(int i=x.length-1;i>=0;i--)
the second function: The for-loop is from beginning to the end ,but we want to find the last 0. So that should be -- for(int i=x.length-1;i>=0;i--)

Question two:If possible, identify a test case that does not execute the fault. (Reachability)
The answer:
the first function:x==null will throw a NullPointerException and it doesn't enter the for-loop test ,so there is no fault to execute. Just like this: Input: x=null;y=0 Expected:NullPointerException The real output: NullPointerException
the second function:there is not such a case.

Question three:If possible, identify a test case that executes the fault, but does not result in an error state.
The answer:
the first function: the y doesn't appear in the first position,there is no error. Just like this: Input: x=[0,2,0];y= 2; Expected:1 The real output: 1
the second function: if the for-loop just executes once, that should be ok. Because the first become the last. Just like this: Input: x=[0] Expected:1 The real output: 1

Question four:If possible identify a test case that results in an error, but not a failure.
The answer:
the first function: the y doesn't appear in the x array. Just like this: Input: x=[0,2,0];y= 3; Expected:-1 The real output: -1
the second function: if the for-loop just executes more than once and the 0 appears only once, that should be ok. Just like this: Input: x=[1,0,2] Expected:1 The real output: 1

转载于:https://www.cnblogs.com/ida-xj/p/5264811.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值