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

后端 未结 8 747
深忆病人
深忆病人 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:34

    The reason why is that your exceptions are not unhandled. The unit testing framework is handling the exceptions under the hood and converting them to failures.

    What you need to do instead is to break on thrown exceptions. If you combine this with enabling "Just My Code" (on by default) you should get the behavior you are expecting. Visual Studio will only break when exceptions thrown by your code occur.

提交回复
热议问题