mercredi 21 janvier 2015

Changing Current Time in Akka tests

I know that, using Joda Time, it is possible to change the "current time".



Joda-Time allows you to change the current time. All methods that get the current time are indirected via DateTimeUtils. This allows the current time to be changed, which can be very useful for testing.

Note that changing the current time this way does not affect the system clock.




// always return the same time when querying current time
DateTimeUtils.setCurrentMillisFixed(millis);
// offset the real time
DateTimeUtils.setCurrentMillisOffset(millis);


Can something similar be done within Akka TestKit, so that I can test scheduled events without using "mocked" timeouts?


And if, as I suspect, this is not possible, what would the reasoning behind this design choice be?


Aucun commentaire:

Enregistrer un commentaire