API Testing · Senior · Question 53 of 75
How do you test time-dependent API behaviour like token expiry deterministically?
- 1Inject a controllable clock or short test-only lifetimes
- 2Change the system clock on the shared test server
- 3Wait for the real token lifetime of one hour in CI
Show the answer
Correct answer: Inject a controllable clock or short test-only lifetimes
Explanation
Controlled time makes expiry, scheduling and daylight saving tests fast and repeatable.