1) Understand the type of error:
Fault:a static defect in the software. "A statically generated error in the software. "Failure:external, incorrect behavior with respect to the requirements or other description of the expected behavior." The performance of the department, the incorrect behavior, the requirements of the intended behavior, or other description. "Error:an incorrect internal state," the manifestation of the some fault. "An incorrect internal condition is a form of error. 】2) RIP model:Infectious propagation transmission of reachability infection3)Tarantula formula:4) Program use case analysis:Requirements: Give two programs below, each giving a test case, and the use case has incorrect results. Answer four questions separately: ① resolution error (fault). ② if possible, identify test cases where errors are not executed. ③ if possible, identify test cases that have performed the error but have not come to the wrong conclusion. ④ if possible, identify a test case that gets the error but does not get the failure conclusion. Program 1:
1 Public intFindLast (int[] x,inty) {2 //effects:if x==null Throw nullpointerexception3 //else return the index of the last element4 //In x that equals Y.5 //If No such element exists, return-16 for(intI=x.length-1; i > 0; i--)7 {8 if(X[i] = =y) {9 returni;}Ten } One return-1; A } - //test:x=[2, 3, 5]; y = 2 - //expected = 0
Reply:
The judging conditions in the ①for cycle should be i>=0 and should not be i>0.
② if x=0, the for loop is not passed, so the wrong code location is not executed.
③ if an element of equal size x and Y is not the first position in X, then the line of code is run and no error is made.
For example: x=[1,2,3,4,5] y=3, then you can go through the line of code and no errors will occur.
④ when the number of elements in X is only one, there is a case where error is not failure.
Program 2:
1 Public Static intLastzero (int[] x) {2 //effects:if x==null Throw nullpointerexception3 //else return the index of the last 0 in X.4 //Return-1 If 0 does not occur in X5 for(inti = 0; i < x.length; i++)6 {7 if(X[i] = = 0) 8 {9 returni;Ten } One } A return-1; - } - the //test:x=[0, 1, 0] - //expected = 2
Reply:
①for (int i = 0; i < x.length; i++) has an error, should be for (int i = x.length-1; I >= 0; I-)
② All test cases go through the wrong line of code.
③ when there is only one element in X, such as x=[1], then the line of code that runs the error does not have a bug.
④ when there are 0 o'clock in an array of x, there will be a case where error is not failure.
"Software Testing" error analysis (HOMEWORK2)