|Next||Pigs in Space||14|
Suppose someone pays us for a year of service
They should get the next bill after 335 days
How are you going to unit test that?
Put like that, the answer is obvious
But I've seen plenty of tests that did sleep 60 to wait for something to happen
No object ever calls time()
If you want the current time, you call Moonpig->env->now
In the test environment, Moonpig->env returns a Moonpig::Env::Test object
This object has ->stop_clock and ->elapse_time methods etc.
Moonpig->env->elapse_time(86_400 * 40); # Now 40 days go by
In the live environment, these methods are absent
|Next||Copyright © 2013 M. J. Dominus|