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
#2949 is a great new feature, thank you. While trying to make use of it in Spring Boot, I came across a situation that would benefit from the consumer of the argument being able to throw checked exceptions:
In this example, request is an org.apache.hc.client5.http.classic.methods.HttpPost and getUri() and getContent() throw URISyntaxException and IOException respectively. As a result, the above snippet does not compile.
I can work around this by using AssertJ's ThrowingConsumer:
As you can see, it requires a cast which is ever so slightly inelegant. It also won't help a Mockito user who doesn't use AssertJ. Would you consider adding a ThrowingConsumer interface to Mockito along with a variant of assertArg that takes a ThrowingConsumer rather than a Consumer?
The text was updated successfully, but these errors were encountered:
Yes that sounds like a useful alternative API! I am not sure if we need to keep both in Mockito 6, but that we will need to see. Do you mind sending us a PR with the new API and corresponding tests? Thanks!
#2949 is a great new feature, thank you. While trying to make use of it in Spring Boot, I came across a situation that would benefit from the consumer of the argument being able to throw checked exceptions:
In this example,
request
is anorg.apache.hc.client5.http.classic.methods.HttpPost
andgetUri()
andgetContent()
throwURISyntaxException
andIOException
respectively. As a result, the above snippet does not compile.I can work around this by using AssertJ's
ThrowingConsumer
:As you can see, it requires a cast which is ever so slightly inelegant. It also won't help a Mockito user who doesn't use AssertJ. Would you consider adding a
ThrowingConsumer
interface to Mockito along with a variant ofassertArg
that takes aThrowingConsumer
rather than aConsumer
?The text was updated successfully, but these errors were encountered: