【软件测试】作业二:fault & error & failure
REVIEW:
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)
Reachability: The location or locations in the program that contain the fault must be reached
Infection: The state of the program must be incorrect
Propagation: The infected state must cause some output or final state of the program to be incorrect
Software Testing Techniques
HOMEWORK:
1.Identify the fault.
(1) 'i > 0' should be 'i >= 0';
(2) it returns to the first '0' but not the last '0', I have 2 ways to correct it:
#1:
int k = -1; for (int i= 0; i< x.length; i++) { if (x[i] == 0) { k = i; } } return k;
#2:
for (int i= x.length - 1; i >= 0 ; i--) { if (x[i] == 0) { return i; } } return -1;
2.If possible, identify a test case that does not execute the fault. (Reachability)
(1) Test case: x = null.
(2) It always execute the fault.
3.If possible, identify a test case that executes the fault, but does not result in an error state.
(1) Test case: x = [1,2,3 ]; y = 3; Expected: 2; Actual: 2.
(2) It's impossible.
4.If possible identify a test case that results in an error, but not a failure.
(1) Test case: x = [1,2,3 ]; y = 4; Expected: -1; Actual: -1.
(2) Test case: x = [1,2,0 ]; Expected:2; Actual:2.