New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic extraction of aggregate exceptions makes it harder for me to test #696
Comments
You're specifically talking about the |
Something like |
That would be a global setting. Did you try |
You probably mean Unfortunately that also unwraps (it just calls the normal |
@dennisdoomen I've taken a look at this and written some tests which confirm that current ShouldThrowExactly will work when an AggregateException is thrown. This is not the behaviour I would expect either, and would instead expect it to only work for the inner exception type. Is this how it's meant to work or is this an issue? I'm happy to write a fix for this if needed. |
The general guidelines are:
However, I'm in doubt about the |
From what I read here, one expected way to handling unwrapping of
Should recursively check if a thrown
On the other hand
should not check
|
Exactly |
I’ll create an issue and a PR specifically for fixing ThrowExactly and ThrowExactlyAsync, if you guys don’t mind? |
Don't forget to update the docs for that part as well. It should be clear how it is supposed to work. |
@davidomid I've been working on something similar in #1041, but haven't finished it. |
No worries, I'll update the documentation too. @jnyrup Thanks very much, I'll check this out and try and make my changes consistent with yours. |
I want to test a method that is synchronous but calls an asynchronous method and I want to ensure that I use
AsyncMethod().WaitAndUnwrapExceptions()
instead ofAsyncMethod.Result
, however this is currently not easily testable since FluentAssertions automatically unwraps the exception.This is in my opinion a pretty bad idea as it might lead to a false feeling of security when in reality it might cover up a bug, because in reality no one unwraps the exception if I use
.Result
and then I have to catch AggregateException instead of the contained exceptions.Therefore I think it would be best to completely remove the automatic exception unwrapping from assertions. However, if that is not desired for backwards compatibility I would at least like an option to disable the unwrapping in my solution (similiarly to how I can configure how ShouldBeEquivalentTo works).
The text was updated successfully, but these errors were encountered: