How to prevent expected exceptions from breaking the debug test run?

纵饮孤独 提交于 2019-11-29 09:35:00

Did you try running the tests using ctrl-R ctrl-T instead of ctrl-R T?

EDIT If it's not a keyboard shortcut issue, then check out this link. You could try the following as noted there:

  1. Disable "break on user unhandled exceptions" for the exception types you you are encountering here (via Debug -> Exceptions)
  2. Disable "break on user unhandled exceptions" for all exceptions (via Debug -> Exceptions)
  3. Disable "Just My Code"

CTRL + R A works for me without changing any option.

I think the problem you have is because you are running the test project from the Start Debugging (F5) button on the toolbar. If you click the green play button, you will stop in every exception, even expected ones.

To run all tests without stopping in every exception, click on: Test -> Run -> All Tests in Solution or use the shortcut: CTRL + R, A

With the test results window open, CTRL + R, D also works. In the test results window it becomes clear the difference between Run Tests and Debug tests.

@dcp's suggestion looks like it would work for MSTEST, but you might want to consider getting TestDriven.Net. I use it as a test runner almost exclusively and don't have this problem using the right-click "Run Tests in Debug" mode. In addition I find it to be more convenient than the built-in test runner in almost all circumstances.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!