3 ms·
Ok but what I’m really interested in is integration tests that depend on time. Waiting for a set amount of time (i.e. literally calling to wait(5) in the test
by otikik 3y ago
Ok but what I’m really interested in is integration tests that depend on time.
Waiting for a set amount of time (i.e. literally calling to wait(5) in the test code) is slow and, even worse than that, flaky. If the test server is busy it might take it longer than 5 seconds to do what the test needs to happen.
The best approach I have found so far is “pulling for the side effects” (i.e. if the test is awaiting the creation of a flobber object, keep pulling the list of flobber objects until a new one pops up). This is not always possible (the interface for pulling the flobber objects is not always available) and it is also inconsistent with multiple threads/processes(one thread might have the new flobber and tell your test that everything is ok, but the next step in the test you happen to be served by a different thread which doesn’t have the new flobber yet).
- MoreQARespect 3y agoMy approaches: 1. libfaketime 2. Make the test resilient to changing time 3. Dependency inject at an even higher level
- groestl 3y agoA multi-tenant timeline (i.e. a tenant local clock) with a side channel for the testing harness to modify the time is what I found most practical when doing integration tests, and the test itself depends on time. (Edit: when testing Java servers)