Software Test Job Two

Source: Internet
Author: User

(1) FindLast

public int FindLast (int[] x, int. y) {//effects:if x==null thrownullpointerexception//else return the index of the last  element//In X that equals y.//if no such element exists, return-1for (int i=x.length-1; i > 0; i--) {If (x[i] = = y) {return i;}} return-1;} Test:x=[2, 3, 5]; y = 2//expected = 0

(a) Identify the fault:

for (int i=x.length-1; i > 0; i--), "i>0" should is "i>=0", otherwise, the 0 index can not is included

(b) If possible, identify a test case this does not execute the fault. (reachability)

Test:x=null;y=1;

Expected=null;

fact = null;

(c) If possible, identify a test case this executes the fault, but does not the result of an error state.

test:x=[3,2,5];y=2

expected=1;

fact = 1;

(d) If possible identify a test case this results in an error, and not a failure.

test:x=[3,2,5]; Y=6

expected =-1;

fact =-1;

(2) Lastzero

public static int Lastzero (int[] x) {//effects:if x==null thrownullpointerexception//else return the index of the last 0 in X.//Return-1 If 0 does not occur in xfor (int i = 0; i < x.length; i++) {if (x[i] = = 0) {Return i;}} return-1 ; }//test:x=[0, 1, 0]//expected = 2

(a) Identify the fault:

for (int i = 0; i < x.length; i++), order should is from high to low, should is "for (int i=x.length-1; i > 0; i--) "

(b) If possible, identify a test case this does not execute the fault. (reachability)

No possible

(c) If possible, identify a test case this executes the fault, but does not the result of an error state.

TEST:X=[1]

Expected=-1;

fact =-1;

(d) If Possible identify a test case this results in an error, and not a failure.

test:x=[1,0,1]

expected = 1;

fact = 1;

Tips

Software fault:a static defect in the software ( the design error in the software is that the code itself is wrong)

Software failure:external, incorrect behavior with respect to the requirements or other description of the expected Beha Vior (failure, not as expected, shown)

Software Error:an incorrect internal state which is the manifestation of some fault (during operation)

Fault, error---failure, defects in the software generate error at run time, and when error accumulates to a certain extent, it will fail, these are bugs

Software Test Job Two

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.