-
-
Notifications
You must be signed in to change notification settings - Fork 683
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
assertThatThrownBy.doesNotThrowAnyException()
fails when no exception is thrown
#2517
Comments
assertThatThrownBy.doesNotThrowAnyException()
fails when no exception is thrown
You already have the comment. I think the failure came from the In code, Assertions.assertThatThrownBy(() -> { // expects this part throw any exception
thisFunctionDoesNothing();
})
.doesNotThrowAnyException(); You should've done like, Assertions.assertThatCode(() -> {
thisFunctionDoesNothing();
})
.doesNotThrowAnyException(); |
That's true and i used I'm sorry for not explaining that in the OP. |
I agree Having said that, we think it is natural for |
as long as this happens, i'm happy! at least, I don't have to explain this to any new colleague joining my team. |
Seems to be a great feature! If possible, I'd like to do some investigation and try to work on it 😄 |
We are already looking at it @hezean but thanks! |
What I miss is this feature to be able to ignore certain exceptions:
What do you think about this idea? |
@pandoras-toolbox yep why not ? I would probably go with assertThatCode(() -> { thisFunctionDoesNothing(); })
.doesNotThrowAnyExceptionExcept(NoSuchElementException.class, IOException.class); could you create a new issue for this? |
Great! I created it. |
Summary
Duplicate of #1787 because that is closed:
Example
And i get the exception:
The text was updated successfully, but these errors were encountered: