Skip to content

Confusing behavior of AbstractCompletableFutureAssert.failsWithin #3587

@vladykin

Description

@vladykin

Describe the bug

Sometimes I need to verify that the future completed with exception, but don't care with which exactly.
Used assertThat(future).failsWithin(...) for that. But, to my greatest surprise, found that assertThat(future).failsWithin(...) passes when the future doesn't complete at all, neither successfully, nor exceptionally.

  • assertj core version: 3.26.3
  • java version: 17
  • test framework version: junit 5

Test case reproducing the bug

    // a future that doesn't complete
    CompletableFuture<Void> future = new CompletableFuture<>();
    // the next assertion passes as if future has failed --- this is counterintuitive
    assertThat(future).failsWithin(Duration.ofMillis(100));
    // the next assertion fails, because the future hasn't actually failed --- this makes sense
    assertThat(future).hasFailed();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions