Sample code for "Time Travel Testing" presentation: Watch Video
Tips for how to handle testing code that requires the passage of time to pass. This includes asynchronous code & code dependent on dates/times.
- Avoid - Factor out the code to be tested separately, from the async code.
- Fake - Fake out the code to provide the current date so you can control the passage of time at will, within your tests.
- Expect - Use XCTest expectations to wait for async code to be complete.
- Count - Use the operationCount of the subject’s OperationQueue and the main OperationQueue to tell when all operations are complete.