Consuming and Manipulating Data

‚   ‚  


Testing and Debugging

Create a unit test plan

  • Testing is the process of executing a program with the intention of finding errors. You should design an effective test plan to ensure that your application is free from all likely defects and errors.

  • Unit testing ensures that each unit of an application functions precisely as desired. It is the lowest level of testing.

  • Integration testing ensures that different units of an application function as expected by the test plan after they are integrated.

  • Whenever code is modified or a new feature is added in an application, you should run all the existing test cases, along with a new set of test cases, to check the new feature. This helps you develop robust applications.

Implement tracing

Configure and use trace listeners and trace switches
  • Listeners are objects that receive trace and debug output. By default, there is one listener, DefaultTraceListener , attached to the Trace and Debug classes. This listener displays the messages in the Output window.

  • Debug and Trace objects share the same Listeners collection. Therefore, any Listener object added to the Trace.Listeners collection is also added to the Debug.Listeners collection.

  • Trace switches allow you to change the type of messages traced by a program, depending on a value stored in the XML configuration file. You need not recompile the application for this change to take effect; you just restart it. You need to implement code to display the messages, depending on the value of the switch.

  • Visual Basic .NET preprocessor directives allow you to define symbols in an application, mark regions of code, and conditionally skip code for compilation.

Display trace output
  • The Trace and Debug classes can be used to display informative messages in an application when the DEBUG and TRACE symbols are defined, respectively, at the time of compilation.

  • By default, both the TRACE and DEBUG symbols are defined in the Debug configuration for compilation, but only the TRACE symbol is defined for the Release configuration of compilation.

Instrument and debug a Windows service, a serviced component, a .NET Remoting object, and an XML Web service

Configure the debugging environment
  • The Conditional attribute allows you to conditionally add or skip a method for compilation, depending on the value of the symbol passed as a parameter to the attribute.

Create and apply debugging code to components and applications
  • You can attach the debugger to a running process (either local or remote) with the help of the Processes dialog box.

  • When you attach a debugger to the ASP.NET worker process aspnet_wp.exe , it freezes the execution of all other Web applications on that server.

  • You should have mdm.exe running on the remote machine in order to perform remote debugging.

  • To debug a Windows service, you must attach a debugger to the process in which the Windows service is running.

  • To debug COM+ library applications, you must attach a debugger to the process in which the client application is running.

  • To debug COM+ server applications, you must attach a debugger to the dllhost.exe process in which the COM+ server application is running.

  • To debug a .NET remoting object, you must attach a debugger to the process in which the remoting server application is running. In case the object is hosted in IIS, you need to attach a debugger to the aspnet_wp.exe process.

  • To debug a Web service, you need to attach a debugger to the aspnet_wp.exe or the client application that is calling Web methods of the Web service.

  • The System.Web.TraceContext class can be used to display trace messages in a Web application. These messages can be easily viewed by using the trace viewer utility or at the end of the page output. ASP.NET displays various page request details, along with any custom trace messages from the code.

  • To enable ASP.NET tracing for a single page, set the trace attribute of the Page directive to true .

Provide multicultural test data to components and applications
  • Test the application's data and user interface to make sure that they conform to the locale's standards for date and time, numeric values, currency, list separators, and measurements.

  • If you are developing for Windows 2000 or Windows XP, test your application on as many language and culture variants as necessary to cover your entire market for the application. These operating systems support the languages used in more than 120 cultures/locales.

  • Prefer using Unicode for your application. Applications using Unicode will run fine without making any changes on Windows 2000 and XP. If your application uses Windows code pages instead, you will need to set the culture/locale of operating system ‚ according to the localized version of application that you are testing ‚ and reboot after each change.

  • While testing a localized version of an application, make sure that you use input data in the language supported by the localized version. This will make the testing scenario close to the scenario in which the application will be actually used.

Execute tests
  • Debugging is the process of finding the causes of errors in a program, locating the lines of code that are causing the error, and fixing the errors.

  • When an exception is thrown by an application, you can either choose to continue execution or break into the debugger (in order to start debugging operations such as step-by-step execution). You can customize this behavior for each exception object by using the Exceptions dialog box.

Use interactive debugging

  • The three options available while performing step-by-step execution are Step Into, Step Over, and Step Out.

  • Breakpoints allow you to mark code that signals the debugger to pause execution. After you encounter a breakpoint, you can choose to continue step-by-step execution or resume the normal execution by pressing F5 or by clicking either the Resume or the Continue button.

  • The various tool windows ‚ such as Me, Locals, Immediate, Autos, Watch, and Call Stack ‚ can be of great help in tracking the execution path and the status of variables in the process of debugging an application in Visual Studio .NET.

Log test results

  • The System event log provides a central repository for various issues that an application might encounter while it is executing. Using an event log to record such messages not only makes the job of system administration easy, but it also allows other applications to take appropriate action when an entry is written to a log.

  • Multiple event sources can write into an event log. However, an event source can be used to write into only one event log.

  • Performance counters are organized in categories, and each category defines a specific set of performance counters.

  • The process of reading a performance counter value is called sampling the performance counter. The process of updating a performance counter value is called publishing a performance counter.

Resolve errors and rework code
  • The most important thing about resolving errors is to be systematic. Use the ASP.NET debugging tools to verify the location of the error in your code. Then correct the code to remove the error.

  • After reworking the code, it is crucial to run the same test that identified the error in the first place. The reworked code should pass the test without error.

Control debugging in the Web.config file
  • ASP.NET Tracing also can be enabled at the application level by setting the enabled attribute of the < trace> element to true in the application-wide web.config file.

Use SOAP extensions for debugging
  • Because SOAP extensions have full access to the SOAP message stream (both requests and responses, before and after serialization), they're useful whenever you suspect a protocol-level error in your code. You can use a SOAP extension to inspect and modify messages between Web services clients and servers.


‚   ‚  
Top


MCAD. MCSD Training Guide (Exam 70-310. Developing XML Web Services and Server Components with Visual Basic. NET and the. NET Framework)
MCAD/MCSD Training Guide (70-310): Developing XML Web Services and Server Components with Visual Basic(R) .NET and the .NET Framework
ISBN: 0789728206
EAN: 2147483647
Year: 2002
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net