Software Testing (ii) Failure, Error & Fault

Source: Internet
Author: User

Knowledge Review

Errors in software testing are divided into three main types:Failure, error, and Fault.

Here's an analysis of their differences:

definition of fault : abnormal conditions that may result in system or function failure ( abnormal condition that can cause an element or An item to fail.), which can be translated as "fault".    Definition of error : The difference between a calculated, observed, or measured value or condition , with a true, prescribed, or theoretically correct value or condition (discrepancy between a computed, observed or measured value or condition and the true, specified, or theoretically correct value or condition.), can be Translated as "error". Error is the internal state of the system that can cause the system to appear failure.

Failure Definition : When a system fails to perform the required function, it is failure, which translates to "failure". (Termination of the ability of anelement or an item to perform a function as required.)

   Analysis of three relationships :
    • As humans try to cover all the actual failure scenarios through the above 3 basic terms, there is a "Fault - Error-Failure". That is, the failure occurs, resulting in an error that could cause the system to weaken or lose its function .
    • When Fault is another component/system failure, there is Failure (Fault), error-Failure, and error when Fault is said to be a component state error (Fault)- > Error-Failure.
    • In fact, this is a recursive loop relationship, the recursive relationship must have a definite end condition to be established, the condition is to find root cause, otherwise you will not be able to complete a failure analysis.

  Example :

  The patient tells the doctor his own symptoms, the body does not work healthily –failures

The doctor wants to find out the root cause of the disease, such as virus –fault

Patients with abnormal physical condition, such as high blood pressure, irregular heartbeat, etc. –errors

Example (HOMEWORK2)

  Program 1:

1  Public intFindLast (int[] x,inty)2{//effects:if X==null Throw3 NullPointerException4    //else return the index of the last element5    //In x that equals Y.6    //If No such element exists, return-17     for(inti=x.length-1; i >0; i--)8    {9         if(X[i] = =y)Ten        {  One           returni; A         }  -     } -      return-1;  the }  - //test:x=[2, 3, 5]; y = 2 - //expected = 0       

  Solution:

  1.Fault: The loop condition is not set, I > 0 will cause the loop to fail to the first item of the array, should be changed to I >= 0.

2. When the array x is empty, a null pointer error is thrown, the loop cannot be executed, and the fault described above is not executed.

3. Error can be avoided as long as the array x[0] is not the only element equal to Y, such as test case x = [1, 2, 3, 4, 5, 6], y = 2, so that the result is returned expected = 1, the result is correct.

4. When the array has only one element, because the loop cannot access the first element (X[0]), the loop cannot be performed and returns 1 forever, leading to error. At this point the failure produces an unknown, and if the only element is not equal to Y, then failure will not be produced. Test Case x = [1], y = 2, at this time return-1, only error, no failure.

  Procedure 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; - } - //test:x=[0, 1, 0] the //expected = 2

  Solution:

  1.Fault: Loop error, from the previous traversal, encountered the first 0 to return its subscript, the loop should be changed to for (int i=x.length-1; i >= 0; i--).

2. The fault is always executed because the program has been traversed in the past and the loop is executed at least once.

3. The loop does not cause error if it cannot be executed, that is, the array is empty. In addition, if the array has only one element, this will not cause an error regardless of how the result is traversed.

4. When an array has more than one element and only one element is 0 o'clock, the loop returns the subscript of the first element equal to 0, causing error. But since only one element is equal to 0, it is also the subscript of the last element equal to 0, then failure will not be generated. Test Case x =

[1,0,1],expected=1, this time only error, no failure.

Software Testing (ii) Failure, Error & Fault

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.