Tim
Tim

Reputation: 99606

Possible to make the VS debugger pause only when an exception different from the expected one is raised?

I wrote a test method to test another method, with input data randomly generated. So in different runs of the test method, different inputs are randomly generated, in order to provide good coverage of the input space.

The test method is supposed to pass, when the method being tested raises an exception instance of a specific exception type InvalidDataException. I did it by adding an attribute to the test method:

[ExpectedException(typeof(InvalidDataException))]

But the test method may also raise an exception instance of an unexpected exception type different from InvalidDataException. So I would like to debug the test method.

In Visual Studio 2015 for C#, when I am debugging the test method, the debugger pauses when an exception instance is raised, whether the exception instance belongs to InvalidDataException or an unexpected different exception type. Is it possible to make the debugger pause only when an exception instance of an exception type different from the one expected (i.e. InvalidDataException) is raised?

Thanks.

Upvotes: 0

Views: 113

Answers (1)

Kieran
Kieran

Reputation: 13

Visual Studio does allow you to only break on certain exceptions. To set the settings go to the debug menu -> Windows -> Exceptions Settings. From there you can select which exceptions the debugger will break on.

Upvotes: 1

Related Questions