Software Test HOMEWORK02:

Software Test HOMEWORK02

The first test case:

                              

1. Identify the fault:

  As we can see, there is a fault marked in the red circle on the figure above. Because the judgment condition of the loop is i > 0, the program can not enter the loop when i = 0.

  The judgment condition is supposed to i >= 0. In that case, if test : x = [2,3,5]; y = 2, the actual output is “-1” which not equal to the expected.

2. a test case that dose not execute the fault:

     x = null ; y = 2

     Expected: Null Pointer Exception

     Actual: Null Pointer Exception

3. a test case that executes the fault, but does not result in an error state:3

     x = [3,5,2] ; y = 2  Or  x =[3,2,5] ; y = 2

     Expected: 2                 Expected: 1

     Actual: 2                     Actual:1

  Because the error state is i = 0 when the condition is i > 0 . But if the program return i before i change to 0, it can avoid the error state.

4. a test case that results in an error, but not a failure:4.

     x = [1,3,5] ; y = 2

     Expected: -1

     Actual: -1   

  In that case the program will reach the state that i = 0, but there is no “2” in elements of x, so it will not result in a failure.

 

The second test case:

                               

1. Identify the fault:

  As we can see, there is a fault marked in the red circle on the figure above. The loop starts by index = 0, and the array is searched in the order of forward and backward,which is marked by the red circle. In this order, the program “return i”, returns the index of the first 0 element in the array x.

  And in my opinion, there is supposed to change the order of this for loop and the same as the first test case. For example:

              for(int i = x.length-1; i >= 0; i--)

2. a test case that dose not execute the fault:

    x = null

    Expected: Null Pointer Exception

    Actual: Null Pointer Exception

  In those cases, the program will not execute the for loop.

3. a test case that executes the fault, but does not result in an error state: 

     x = [1,1,1]

     Expected: -1

     Actual: -1

  The error state is i equal to the index of the first 0.

  Once the program executes and there is no 0 in the array, it’s state of i is right. Therefore, the program execute the fault, but avoid the error state.

4. a test case that results in an error, but not a failure:4.

     x = [0,1,1] (an array that only has one 0)

     Expected: 0

     Actual: 0

  The error state is i equal to the index of the first 0. When there is a 0 in the array, the program is in this error state, the actual outcome is the expected and not a failure.

转载于:https://www.cnblogs.com/humeng96/p/6477328.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值