AndWait Matcher
Hamcrest matcher which is waiting (with a timeout) for the expected value
Usage
assertThat(this::receiveMessage, andWait(is(equalTo("Howdy"))));
- this matcher works with the default hamcrest "assertThat"
- first parameter receives a function that will be called until the expected value is present (Success) or timeout (Exception) is received
- you can define a custom timeout by using the second optional parameter of the "andWait" matcher
assertThat(this::receiveMessage, andWait(is(equalTo("Howdy")), 500));
Matcher assertionError example
Expected:
but: [Timeout]
Expected: is "unknown message"
but: was "other message"
TODO
- Feature instead of Thread.sleep(XY)
- Only one AssertionError description instead of having two descriptions - first is a timeout and second is mismatch