码迷,mamicode.com
首页 > 其他好文 > 详细

软件测试:homework2

时间:2017-02-25 17:03:05      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:nbsp   出错   com   src   software   test   require   intern   can   

题目:

技术分享

 

首先我们需要搞懂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

标签:nbsp   出错   com   src   software   test   require   intern   can   

原文地址:http://www.cnblogs.com/mjm212/p/6442051.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!