Disable VS C # Unit testing on exceptions

I want to write unit test to detect an exception that has occurred. Using ExpectedExceptionAttribute, I run the test from within MSVS, and when TestMethod gets into the exception, the debugger goes to the exception, but TestMethod correctly skips and the reports passed.

Is there a flag to tell VS not to interrupt during unit testing?

+5
source share
3 answers

Do not run tests in a debugging session. You have the option "Run selection" or "Debug", select the first one, and everything will be fine.

+11
source

CTRL + ALT + E, , , / .

, .

+4

As an alternative to a specific MS module [ExpectedException], if you need to debug your unit tests, you can explicitly try / catch the exception and the Assert type of exception, for example, made here: How to use Assert to verify that an exception has been raised?

+1
source

All Articles