Search code examples
unit-testingvisual-studio-2019nunitresharpervisual-studio-2022

How do I break on assert failures when debugging?


I am using NUnit 3.13.3 and Resharper 2023.1.1. I am using Visual Studio 2019 and Visual Studio 2022.

In Visual Studio 2019, if I write a test procedure and use the Resharper test runner to debug it, Visual Studio will break on any Assert statement that fails.

If I do the same thing in Visual Studio 2022, Visual Studio will not break when an Assert statement fails. The test runner reports failure, but Visual Studio does not break on the Assert statement.

What configuration steps are required in Visual Studio, NUnit, and/or Resharper to make Visual Studio 2022 break on assert failures? Perhaps I've missed it, but I can find no Visual Studio or Resharper setting relevant to this behavior.


Solution

  • Try to open Debug -> Windows -> Exception Settings, then point to Common Language Runtime Exceptions, press + button and add NUnit.Framework.AssertionException