Reputation: 3593
Is there a way to fix the system clock at a time when running tests with Robolectric? I have some code that's dependent on the day of the week. In rspec, there's the TimeCop gem that allows you to fix a time for the system. Does Robolectric have an equivalent?
Upvotes: 3
Views: 1393
Reputation: 7438
I didn't saw a ready to use feature for set explicit time/date yet.
You can achieve this by creating your own ShadowSystemClock
implementation. Or shadow another class/function from where the date is being collected.
Current SystemClock
shadow implementation
https://github.com/robolectric/robolectric/blob/master/src/main/java/org/robolectric/shadows/ShadowSystemClock.java
Implement own shadow http://robolectric.org/extending/
Upvotes: 1