RejectedSoftware Forums

Sign up

how to test time-based logic

Say I have some functionality that schedules events. Some events could happen every week, some every month. Is there a straight-forward way to mock time so that e.g. setTimer, etc. are sped up, or do I need to artificially do this through modifying the delays I am creating for the test?

Re: how to test time-based logic

Am 11.07.2016 um 18:56 schrieb Øivind Loe:

Say I have some functionality that schedules events. Some events could happen every week, some every month. Is there a straight-forward way to mock time so that e.g. setTimer, etc. are sped up, or do I need to artificially do this through modifying the delays I am creating for the test?

There is no built-in way to add a custom time factor, so you'd indeed
have to add an own layer for that.

BTW, I'm not sure if adding such functionality to vibe.d itself would be
a good idea in general, because it wouldn't usually work without also
modifying time measurements accordingly (i.e. std.datetime).