Details
-
Task
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
None
-
None
Description
CompletableFutureMatcher was originally intended to match successful outcomes of a future. For checking that a future has failed, there exists a CompletableFutureExceptionMatcher. For some reason, though, CompletableFutureMatcher was extended to match exceptional outcomes as well, which makes the code ugly. Also, let's compare the diagnostic messages they provide:
assertThat(failedFuture(new IllegalArgumentException()), CompletableFutureMatcher.willFailFast(NullPointerException.class))
This matcher produces the following result:
org.opentest4j.AssertionFailedError: Expected :true Actual :false
assertThat(failedFuture(new IllegalArgumentException()), CompletableFutureExceptionMatcher.willThrow(NullPointerException.class));
This matcher produces the following result:
java.lang.AssertionError: Expected: a future that completes with an exception that is an instance of java.lang.NullPointerException but: was completed exceptionally with <java.lang.IllegalArgumentException> Expected :a future that completes with an exception that is an instance of java.lang.NullPointerException Actual :completed exceptionally with <java.lang.IllegalArgumentException>
I propose to remove the exception checking part from CompletableFutureMatcher and replace it with CompletableFutureExceptionMatcher.
Attachments
Issue Links
- links to