jeudi 8 juin 2017

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.

Aucun commentaire:

Enregistrer un commentaire