For making asynchronous assertions.
For typical use, create an anonymous subclass inline, and implement the {@link #poll()} method:
{@code}new Poller( times(10), every(100, MILLISECONDS) ) public void poll() { assertThat(someMethodCall(), is("Success")); } }; }
This assertion will be called a number of times (configurable by using the different constructors). The first poll is tried immediately, so if you specify 3 attempts with 1 second pause, the total execution time will be about 2 seconds.
This class catches any {@link AssertionError} thrown in the first n-1 attempts. If any other kind of Exception is encountered, or an AssertionError is thrown at the last attempt then itwill be thrown immediately and your test will fail. All AssertionErrors except the last are swallowed.
For debugging purposes you may call {@link #loudly()} in your poll method, and interim AssertionErrors will be logged to System.out rather than being simply ignored.