concurrentunit
concurrentunit copied to clipboard
Support AssertJ
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);