testing and debugging in vb net l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Testing and Debugging in VB.NET PowerPoint Presentation
Download Presentation
Testing and Debugging in VB.NET

Loading in 2 Seconds...

play fullscreen
1 / 24

Testing and Debugging in VB.NET - PowerPoint PPT Presentation


  • 898 Views
  • Uploaded on

Testing and Debugging in VB.NET. Testing and Debugging Types of errors Testing and debugging strategies Bug Lists Exception Handling Debugging tools The Command window The Locals Window. Types of Errors. Syntax errors Execution errors Logic errors. Syntax (Compile-time) Errors.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

Testing and Debugging in VB.NET


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. Testing and Debugging in VB.NET • Testing and Debugging • Types of errors • Testing and debugging strategies • Bug Lists • Exception Handling • Debugging tools • The Command window • The Locals Window University of South Alabama School of CIS

    2. Types of Errors • Syntax errors • Execution errors • Logic errors University of South Alabama School of CIS

    3. Syntax (Compile-time) Errors • Caused by incorrectly constructed code • misspelling a keyword • comma out of place • Detected at compile time • it is a recommended practice to first correct all syntax errors before doing execution-based testing University of South Alabama School of CIS

    4. Execution (Run-time) Errors • Occur during program execution • When program is syntactically correct • Program usually stops running (crashes) • Usually caused by computer’s attempt to carry out an impossible operation, such as • Division by zero • Read past end-of-file • Type mismatch University of South Alabama School of CIS

    5. Logic Errors • Occur when program does not perform according to its specifications • Syntactically correct, executes without any RTEs, but produces incorrect results due to faulty program logic • Unlike syntax and execution errors, logic errors cannot be detected by the computer system, but by • Inspections (code reviews) • Observation (execution-based testing, observing incorrect results) University of South Alabama School of CIS

    6. Getting Help with Errors • Help button delivers help with exceptions • Break button invokes code window at point of error University of South Alabama School of CIS

    7. Testing and Debugging Strategies • Thoroughly understand what each section of code is trying to accomplish • Test systematically • using stubs (top-down) • and drivers (bottom-up) • Code and test incrementally • “code a little, test a lot, save a lot” • Pay close attention to text of any error messages • Note what code editor highlights University of South Alabama School of CIS

    8. Testing and Debugging Strategies (cont.) • Test cases • Black box - based on the program specifications • White box - based on programming logic • Consist of input data and expected result • Test with large and small values of numbers and strings • Test around and at boundary values • Test your program on other computer systems • Re-run tests after making changes to program (regression testing) University of South Alabama School of CIS

    9. Testing and Debugging Strategies (cont.) • Use debugging tools and/or message boxes to examine the results of actions • Understand the state of variables, controls, and files and databases at the time of the error • prior conditions contribute to problem • example: use of .Read method failed because end-of-file condition was already true • Get someone else to run your program • they might test something you didn’t think of • Test how your program handles errors • Exception handling University of South Alabama School of CIS

    10. Bug Lists • Use bug lists as you test and debug • A bug list is simply a list of failures encountered during execution-based testing • Informal, handwritten lists are acceptable • Three columns of information in a bug list • A description of the failure • A column to check once you have repaired the error • A column to check once you have verified that the error has been repaired University of South Alabama School of CIS

    11. Bug Lists (cont.) • Use bug lists to help you remember • what failures need to be found and repaired • which repairs need to be verified • Add more failures to the list as you encounter them during retesting • Unless you need to keep the list for documentation purposes, simply throw it away when done University of South Alabama School of CIS

    12. Testing and Debugging Strategies (cont.) • Bug lists are useful for test and debug process University of South Alabama School of CIS

    13. Exception Handling in VB.NET • An exception is • A runtime error • A class containing information about a runtime error • When an invalid operation occurs, it is said that “an exception will be thrown” • This means that VB will check to see if your program is prepared to handle the exception • Or else an error message is displayed and your program is terminated University of South Alabama School of CIS

    14. Writing an Exception Handler • An Exception is handled inside of a Try statement • Write a code block suspected of causing a RTE inside the Try block • Write the exception handler inside the Catch block • An exception handler is code that is executed whenever a runtime error occurs inside the Try block • When a RTE occurs inside a Try block • Your program is interrupted • Control is passed to a Catch handler University of South Alabama School of CIS

    15. Exception Handling in VB.NET Try ' Starts a structured exception handler. ' Place executable statements that may generate ' an exception in this block. Catch [optional filters] ' This code runs if the statements listed in ' the Try block fail and the filter on the Catch statement is true. [Additional Catch blocks] Finally ' This code always runs immediately before ' the Try statement exits. End Try ' Ends a structured exception handler. University of South Alabama School of CIS

    16. Exception Handler - Example connBus.ConnectionString = "Provider=.Jet.OLEDB.4.0…” Try connBus.Open() Catch DbErr As Exception MsgBox("Run-time error: " & DbErr.Message & _ ”; source = " & DbErr.Source) Throw ‘* lets another handler handle the error Finally MsgBox(“Call the system administrator”) End Try University of South Alabama School of CIS

    17. The Debug Toolbar Step Into Step Over Step Out Show next statement Restart Breakpoints Stop Break Continue University of South Alabama School of CIS

    18. Debugging Tools • The Breakpoint • Enables you to suspend program execution when a specified line of code is encountered • Set by putting insertion point in the line and clicking the breakpoint button • Breakpoints are indicated by brown highlight • You may have multiple breakpoints set in the program • Clicking the run button again causes program execution to continue to next breakpoint or pause • Debugging menu has “Toggle breakpoints” and “Clear all breakpoints” choices University of South Alabama School of CIS

    19. Debugging Tools (cont.) • Quick Watch • Allows you to examine the value of an expression • Program must be halted • Paused at a breakpoint • Paused using the pause button • Paused by a runtime error • Highlight expression or variable • Debug | QuickWatch University of South Alabama School of CIS

    20. Debugging Tools (cont.) • The Calls button • Enables you to examine the calls stack, which consists of the procedures that are active when the program is paused with a breakpoint • Window shows sequence of active calls • Double-click to display in code window University of South Alabama School of CIS

    21. Debugging Tools (cont.) • Stepping through code • Step To Cursor: executes statements and pauses at the line where cursor sits in code window • Step Into: executes next statement and steps into a procedure, pausing at its first statement • Step Over: executes next statement, executing a procedure call without stepping into procedure; pauses at the next line of the current routine • Step Out: executes remaining statements in a procedure and pauses at the first line after the procedure call in the calling procedure University of South Alabama School of CIS

    22. The Command Window – Immediate mode • Allows immediate execution of code • View current variable values with ? statement if program is paused • Set variable values University of South Alabama School of CIS

    23. University of South Alabama School of CIS

    24. The Locals Window • Automatically displays all of the declared variables in a procedure • Includes value and data type • Updated each time program enters break mode University of South Alabama School of CIS