简体   繁体   中英

Visual Studio 2012 Unit Test client and service debug

Dumb question but for some reason I just can't seem to figure out how to debug a unit test, hit a breakpoint on the client and step into a web service. In VS 2010 I just set my solution to be a Multiple Startup Projeects and set the debug to the client UI test and also the web service. When my breakpoint hit in the UI test I could step into the web service. In VS 2012, I don't see a way to do that. Can anyone help?

  1. Start the website without debugging (if it's not already running).
  2. Put a breakpoint in your unit test.
  3. Start your unit test.
  4. When the breakpoint is hit, use Debug > Attach to Process to attach to iisexpress.exe .

The official instructions are wrong. They say to attach the debugger first, but if you do that, the commands to start your unit test are disabled.

Always having to manually attach can be a pain. There doesn't seem to be a way to do it quickly from the Command Window . If I had to do a lot of debug cycles, I'd temporarily copy the test code into the web application somewhere that would get run at startup.

Run two instances of Visual Studio. In one instance, debug the website. In the other, run the unit tests.

To keep the unit-test instance from trying to start the website, select the website project, click View > Properties Window , and ensure Always Start When Debugging is False .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM