Why doesn't Visual Studio break on exceptions when debugging unit tests?

后端 未结 8 754
深忆病人
深忆病人 2020-12-29 02:53

When I attempt to debug a unit test that fails because of an unhandled exception in my code, I expect Visual Studio to break on the unhandled exception so I can inspect the

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 03:20

    By default, even if you do a debug build, MSTest does't give you debugging (with break points, etc), unless you actually tell it to explicitly "Debug Unit Tests".

    It should break on unhandled exceptions in Unit testing, provided you are in a Debug configuration, and you start the Unit Testing using "Debug" - ie: Using Ctrl+R, Ctrl+A instead of Ctrl+R, A to run all tests. In the testing window, there is a "Run" and a "Debug" menu with the options.

提交回复
热议问题