suhail khan
suhail khan

Reputation: 61

ASP.NET VS2010 MsTest Debugger not stopping at breakpoints

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

Upvotes: 2

Views: 971

Answers (3)

demoncodemonkey
demoncodemonkey

Reputation: 11957

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.

Upvotes: 1

suhail khan
suhail khan

Reputation: 61

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

Upvotes: 2

user596075
user596075

Reputation:

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.

Upvotes: 2

Related Questions