Conversation
|
LGTM :) |
|
I think we can drop my attempt https://github.com/assertj/assertj-core/pull/2516/files |
|
Slightly off topic, I think the existing // why would we expect to have an exception here?
assertThatCode(() -> doStuff()).hasMessage("Boom!");your version with callable is much better in that sense. // reads nicely
assertThatThrownBy(() -> doStuff()).hasMessage("Boom!");Ideally I would replace the existing |
Yes, I tried to say that but with wrong wording 😆 I'm exploring the direction of |
a9145d3 to
976bf14
Compare
|
@joel-costigliola I went with I'd experiment the replacement of |
|
With the new assertion hierarchy ( We might add it in a second round, keeping only |
4a737e8 to
77f0751
Compare
2e46f25 to
e1f4a9a
Compare
e1f4a9a to
4b0a655
Compare
| } | ||
|
|
||
| @Override | ||
| protected void execute(Callable<V> actual) throws Exception { |
There was a problem hiding this comment.
is it worth specifying that this throws Throwable directly? Shouldn't make much difference but semantically it'd make sense to be able to catch Errors and the likes if testing code that could raise errors directly, which I assume this would do already.
There was a problem hiding this comment.
Right now, it wouldn't catch Throwable or Error instances as the input parameter is a Callable, and Callable::call allows throwing Exceptions only.
Maybe we should consider if a new Callable-like interface that throws Throwable should be defined instead of relying on the JDK Callable.
@ascopes do you already have a concrete use case that would require it?
There was a problem hiding this comment.
As suggested by @sbrannen in #3314 (comment), a ThrowingSupplier could be defined if we decide that a Callable throwing Exception is not flexible enough.
301ca01 to
c730d18
Compare
Usage examples in
CallableAssert_Demo_Test.This introduces a breaking change for all the
assertThatCode()assertions with aCallablethat don't calldoesNotThrowAnyException()but any other method fromAbstractThrowableAssert.Check List: