Issue
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?
Solution
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/
Answered By - nenick
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.