Debugging unit test does not break on exception

  • Visual Studio 2015 (14.0.25431.01 Update 3)
  • Resharper Ultimate 2018.2.3 (build 2018-09-12)
  • Windows 10 x64 v1803
  • .NET Framework 4.5.2

I have a very simple test:

 [Test]
public void Throw_ex()
{
throw new Exception();
}

When I run the test I get a test fail result and a message as expected:

 

When I debug the test, I am expecting visual studio to pause on the thrown exception to allow me to investigate. Instead, the UI momentarily moves into debug mode (windows move etc) and then the test completes and the output views identical to the above.

I believe the behaviour I desired happened on previous versions of visual studio and resharper although I cannot remember the exact details. Has this behaviour changed or am I misunderstanding something?

0
6 comments

Hello Andy!

 

Thank you for contacting us.

Could you please specify what test framework is used in your project?

Could you please also share the sample solution for which the specified behavior is reproduced?

Thank you.

0

Any news on this issue? I have the same problem with my NET Core 3 unit tests.

0

Hello Alexander,

 

I cannot reproduce the issue in a newly created NUnit Core solution. ReSharper 2019.2.3 test runner works exactly as VS one and stops on exception.

Is there any chance you could share the solution with us in which the problem is reproduced? You can do it privately via 'Submit a request' form.

Thank you.

0
Avatar
Permanently deleted user

Hello Angelina,

just noticed that this post is in the Resharper section. I have this problem only when debugging the test in Rider. In VS it works perfectly. Should I open another issue in the Rider section?

Cheers,

Alex

0

Thank you for the reply, Alex.

 

Please open Run | View Breakpoints and check Any Exception option. Here're some more details on debugging exception - https://www.jetbrains.com/help/rider/Debugging_Exceptions.html.

Please let me know if it helps.

Thank you.

0
Avatar
Permanently deleted user

Thank you Angelina! 

Your anwser solved my problem perfectly. Should have found this my self...

0

Please sign in to leave a comment.