Sponsored Ad

Monday, April 12, 2010

How to Debug/Unit Test C# Application With Visual Studio

 

Debugging is very important part of unit testing. You need to go through every step of code and find that logic is working fine or not. This post will help you to debug/unit test your visual studio application.

Step by Step guide to Debug .NET application:

Step 1: The first step is set a breakpoint in your code by Right click –> breakPoint –> Insert BreakPoint or click on left vertical bar.

How to Debug/Unit Test C# Application With Visual Studio

How to Debug/Unit Test C# Application With Visual Studio

To Remove breakpoint you can Right Click on line –> BreakPoint – > Delete BreakPoint, If you want to Disable breakpoint for sometimes then Right Click on line –> BreakPoint – > Disable BreakPoint

 

Step 2: now Run the program in Debugging mode by pressing F5 or click a Green Button with Debug option.

How to Debug/Unit Test C# Application With Visual Studio

now when you run the program the execution pointer will stop to debug point if application will try to run the same line code.

How to Debug/Unit Test C# Application With Visual Studio

step 3: you can use debug option to debug line by line execution and can know the intermediate values and effect of execution of each line.

to check intermediate values just mouse over the variable name or right click to variable and select quick watch.

How to Debug/Unit Test C# Application With Visual Studio

Debug Options:

How to Debug/Unit Test C# Application With Visual Studio

Stop Debugging: shift + F5

Restart Debugging : Ctrl+shift+F5

Step Into: F11

Step Over: F10

Step Out: shift+F11

Delete All breakpoints Ctrl+Shift+F9

These operation you can do either using keyboard keys or menu.

 

Let me explain you some very important functions:

Step Into: F11: It send the next execution inside the code block, suppose there is a function then it will send execution inside function.

Step Over: F10: Normal execution , execute next statement.

Step Out: shift+F11: Execute all code and bring out the function or any inside code block.

0 comments:

Post a Comment

Sponsored Ad

Related Software Testing Articles

Development Updates

Tech Updates