QA Fundamentals · Senior · Question 26 of 76
How do you test a feature that depends on the current date and time?
- 1Control time through an injectable clock or test hooks
- 2Run the tests only at the times when the feature works
- 3Change the system clock of the shared test server
Show the answer
Correct answer: Control time through an injectable clock or test hooks
Explanation
Testing expiry, schedules and time zones requires controlling 'now'. A fake clock makes the tests fast and deterministic, including edge cases like DST changes.