4 ms·
You can extract the timeout functionality into its own structure then and mock it out during testing. There's usually a solution of some sort, it might just re
by LouisSayers 3y ago
You can extract the timeout functionality into its own structure then and mock it out during testing.
There's usually a solution of some sort, it might just require a bit of rearranging and extraction of concerns.
- aaomidi 3y agoThat’s basically dependency injection
- LouisSayers 3y agoYes, that's my point - they're giving an example for why "you can't do it", and I'm saying even for the example they just gave you can. Create a Timeout class and subscribe to it for a given interval with a callback to what needs to be run. Pass it in as a dependency which can be mocked during testing. Not sure why the downvotes...