AssertException when the probe fails to become true before timeout
// this should complete right after the first probe assertEventually({ return true; }); // test using delegate implementation assertEventually(delegate() { return true; }); assertEventually( { static count = 0; return ++count > 23; }, // make sure every slow/heavy-loaded computers/CI do this unittest // e.g.: Travis-CI due to high number of parallel jobs, can't do it in // time. 1000.msecs, 1.msecs ); // this should never complete and eventually timeout. auto exception = expectThrows!AssertException(assertEventually({ return false; })); assertEquals("timed out", exception.msg);
Checks a probe until the timeout expires. The assert error is produced if the probe fails to return 'true' before the timeout.
The parameter timeout determines the maximum timeout to wait before asserting a failure (default is 500ms).
The parameter delay determines how often the predicate will be checked (default is 10ms).
This kind of assertion is very useful to check on code that runs in another thread. For instance, the thread that listens to a socket.