Skip to content

Conversation

@azplanlos
Copy link

This PR enables the usage of AssertJ next to Hamcrest.

There are several options to perform assertions on a thread:

Fluent usage with SoftAssertions:

final Waiter w = new Waiter();
new Thread(new Runnable() {
  public void run() {
    w.softlyAssertThat("one").isEqualTo("two");
    w.assertAndResume();
  }
}).start();
w.await(1000);

Mutiple soft assertions:

final Waiter w = new Waiter();
new Thread(new Runnable() {
  public void run() {
    SoftAssertions assertions = new SoftAssertions();
    assertions.assertThat("one").isEqualTo("two");
    w.assertThat(assertions);
  }
}).start();
w.await(1000);

Using a consumer:

final Waiter w = new Waiter();
new Thread(new Runnable() {
  public void run() {
    w.assertThat("one", (assertion) -> assertion.isEqualTo("two"));
  }
}).start();
w.await(1000);

Using a lambda function with static imports:

final Waiter w = new Waiter();
new Thread(new Runnable() {
  public void run() {
    w.assertThat(() -> assertThat("one").isEqualTo("two"));
  }
}).start();
w.await(1000);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant