2

Just created a new ASP.NET website using VS2010 (did not change anything)

Clicked on Test menu item, used Test Wizard to generate test. Selected PageLoad of Default page to generate a test.

This has created a test Page_LoadTest ,all works fine as expected apart from debugger does not stops at breakpoint I put in Page_LoadTest test.

Test method generated is as follows

 <TestMethod(), _
 HostType("ASP.NET"), _
 AspNetDevelopmentServerHost("c:\documents and settings\z08763ddev\my documents\visual studio 2010\Projects\WebApplication3\WebApplication3", "/"), _
 UrlToTest("http://localhost:1560/"), _
 DeploymentItem("WebApplication3.dll")> _
Public Sub Page_LoadTest()
    Dim target As _Default_Accessor = New _Default_Accessor() ' TODO: Initialize to an appropriate value
    Dim sender As Object = Nothing ' TODO: Initialize to an appropriate value
    Dim e As EventArgs = Nothing ' TODO: Initialize to an appropriate value
    target.Page_Load(sender, e)
  End Sub

3 Answers 3

2

Instead of selecting Run Selected Tests, there's a drop down arrow for Debug Selected Tests. If you just run your tests, you'll have the behavior you're seeing. No breakpoints will be hit.

But if you specifically select Debug Selected Tests your breakpoints will be hit and execution will be paused for debugging.

1
  • @suhailkhan Then your breakpoints simply aren't getting reached or you don't have them set correctly.
    – user596075
    Commented Feb 16, 2012 at 14:52
2

Apparently using host "ASP.NET" attribute causing breakpoints not to stop. If I change the host type break points works. However I am still trying to figure out how to make breakpoint work in "ASP.NET" host

1

Instead of setting a breakpoint, try adding this line to your unit test:

System.Diagnostics.Debugger.Break();

This will cause the JIT debugger to ask if you want to debug w3wp.exe, and it will let you choose a new instance of Visual Studio to do the debugging.

Not the answer you're looking for? Browse other questions tagged or ask your own question.