3 ms·
If you really want to modify global state while running a test, then you might as well use a dependency injection container and get similar behaviour, entirely
by skrebbel 13y ago
If you really want to modify global state while running a test, then you might as well use a dependency injection container and get similar behaviour, entirely generalized.
You can then have two much simpler clock classes, one for real time and one for fake time.
Personally, I prefer just passing around the clock, though - it makes dependencies between classes crystal clear.
- ExCodeCowboy 13y agoYou get the added benefit of not relying on global state. Which you have to do anyway if you want to parallelize your test suite execution.