软件测试:homework2

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了软件测试:homework2相关的知识,希望对你有一定的参考价值。

题目:

 

首先我们需要搞懂fault,error,failure的区别:

百度搜索到的解释:

Software Fault: A static defect in the software;(eg: virus)
Software Failure: External, incorrect behavior with respect to the requirements or other description of the expected behavior;( eg: high body temperature)
Software Error: An incorrect internal state that is the manifestation of some fault;(eg: some symptoms)

我的理解是:

Software Fault: 在编程中出错的那句话,或者是那个错误的方式
Software Failure: 运行结果与预期的不一样就是导致了一个failure
Software Error: 在测试用例运行中,运行了fault的错误方式,就导致了一个error

 

Answer:

In the first faulty programs:

1、Actual output:-1. Because in the loop i can not get 0, we need to change it.

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

 

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

Array x is a null array, throw NullPointerException.

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

Expected=1

Actual = 1

Although it leads to fault, it doesn’t leads to error. Because when i=1, then return i.

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

Expected = -1

Actual = -1

Although it leads to error, the result is right.

 

In the second faulty programs:

1、Actual output:0 . Because in the first loop x[i]==0,output the i, we need to change it.

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

2、test:x=[]

Array x is a null array, throw NullPointerException.

3、 test:x=[0]

Expected=0

Actual = 0

Although it leads to fault ,it doesn’t leads to error. Because x.length=0;

4、 test:x=[1,2,3]

Expected=-1

Actual = -1

Although it leads to error but the result is right

 

 

以上是关于软件测试:homework2的主要内容,如果未能解决你的问题,请参考以下文章

软件测试错误分析(homework2)

软件测试 homework2

软件测试 homework2

软件测试技术 homework2

软件测试Homework2

Software Engineering homework2