You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
QoL suggestion: fail fast in Assert.Multiple under debugger #4738
While Assert.Multiple is nice for failure reporting on test runs, it is quite bad when you try to debug test compared to regular assert.
with simple assert you get exception on assertion failure and could debug it
with Assert.Multiple you get exception at the end where you probably lost all related test context already and need to put manual breakpoints inside of delegate to be able to debug first failure (or comment Assert.Multiple wrap)
I propose to throw assert exception on first failure if process is under debug (Debugger.IsAttached == true) with some kind of switch for backward compatibility. E.g. for those who use tests with debbugger for any reason or just enjoy having troubles during debugging.
It solves it in the same way commenting out Assert.Multiple would. We’d lose the second, third, etc. error message, and in order to debug through those, the first assertion needs to be commented out or resolved.
Actually I think we just need to follow @RenderMichael proposal and change behavior to throw first-chance exceptions. Having two throw modes doesn't add any value
Activity
OsirisTerje commentedon Jun 26, 2024
Nice idea! Could be enabled using a setting. Would you like to do a PR for this ?
MaceWindu commentedon Jun 27, 2024
Sure #4739
Need some help with:
OsirisTerje commentedon Jul 2, 2024
Yes :-)
Can't think of anything else missing right now.
OsirisTerje commentedon Jul 3, 2024
Need to raise a separate documentation issue for this.
RenderMichael commentedon Jul 8, 2024
I am also interested in this.
Thanks to first-change exceptions, the debugger stops whenever anything throws, even if it is caught (unless Just My Code is enabled).
Therefore you could have something like
And the debugger will still break here.
Alternatively, you could just call
System.Diagnostics.Debugger.Break();directly.This will enable debugger stopping without breaking
Assert.Multiplefunctionality.OsirisTerje commentedon Jul 8, 2024
@RenderMichael But does the PR, which is now merged,solve this for you?
RenderMichael commentedon Jul 8, 2024
It solves it in the same way commenting out
Assert.Multiplewould. We’d lose the second, third, etc. error message, and in order to debug through those, the first assertion needs to be commented out or resolved.MaceWindu commentedon Jul 9, 2024
Such behavior also could be useful. @OsirisTerje any objections to convert new boolean option to enumeration like that:MaceWindu commentedon Jul 9, 2024
Actually I think we just need to follow @RenderMichael proposal and change behavior to throw first-chance exceptions. Having two throw modes doesn't add any value
MaceWindu commentedon Jul 9, 2024
Submited PR #4749
Add support for ThrowOnEachFailureUnderDebugger setting for nunit/nun…
MaceWindu commentedon Jul 9, 2024
Also submitted adapter PR #1188