Thursday, 29 March 2018

Program Testing and Debugging

A software bug (or just "bug") is an error, flaw, mistake, failure, fault or "undocumented feature" in a computer program that prevents it from behaving as intended (e.g., producing an incorrect result).

Most bugs arise from mistakes and errors made by people in either a program's source code or its design and a few are caused by compilers producing incorrect code.

Formal Program Testing
                The software industry is primarily concern with logical errors and hidden run-time errors. Companies expend enormous effort to find the errors before the release. To fix a bug after the release cost a 100 times more; patches must be designed and ship out.Besides the customer are not very happy. So, there is the necessity of program testing before it goes to the end user.
   The industry is concerned with Verification and Validation :
               Validation or appropriate :
                  Techniques for insuring validation :
                         Inspection code at a high level
                         Have the user/customer test software
                         Requires good software specification

                Verification or correctness :
                         Is the program producing the correct answers ?
                         Techniques for insuring verification :
                              Code walk through of inspection
                              Testing

Testing
    Testing is the primary technique for the above two Vs :
        Testing uses input data and observes output.
             There may be additional output then in the final product.
             The evaluation may include more then just the correctness of the output.
             Testing can be at the component level or integrated level.

Debugging
   Debugging is a methodical process of finding and reducing the number of bugs or defects, in a computer program or a piece of electronic hardware thus making it behave as expected. Debugging tends to be harder when various subsystem are tightly coupled, as changes in one may cause bugs to emerge in another.

Difference between Testing and Debugging



Types of Program Errors
  There are three basic errors :
    1. Syntax/Compilation error
    2. Run-time exception error
    3. Logical error

Syntax / Compilation Error
   Error during compiling prevents getting a compiled code. Modern compilers indicate well the location of the error. Sometimes problems with delineators such as semicolons in C or brackets in C++.

Run-time Exception Error
  When you get an error message while running the compiled code. Java gives good error messages indicating the location of the error but that might not be the location of the actual error.Some languages, such as C seem to have only one type of error; segmentation fault or Fortran, index out of bounds.

Logical Error
  These errors are the hardest to correct or detect. The program "runs" but the output is not correct.
     
Tools for detecting and fixing logical error :
      1. Choose test cases well. Try to cover everything with small cases. Try one big case.
      2. Print intermediate value. Use a boolean variable to turn on and off debug printing.
      3. Walk though. Play computer in front of an audience (if you can) and suspect all code especially uncommitted code.

Logical errors generally occur at :
Loops : 
    Check the range of for loops and the boolean expression of while loop.
  
Ifs :
    Check complicated boolean expressions (more than one variables) and especially if you are using negation.

0 Comments:

Post a Comment

Popular Posts

Categories

Android (21) AngularJS (1) Books (3) C (75) C++ (81) Data Strucures (4) Engineering (13) FPL (17) HTML&CSS (38) IS (25) Java (85) PHP (20) Python (83) R (68) Selenium Webdriver (2) Software (13) SQL (27)