9

I've been wondering how one is supposed to properly test functionality that relies on date or time changes with Android. Lets say I have events that need to be processed on the first of every month and the result of this processing depends on the current date / time. I'm missing the possibility to fake a certain date / time in the Android testing framework. How are we supposed to test that kind of things?

Of course one could use an abstraction from real time by querying the date / time not directly from the framework but from an additional entity. Than one could set a fake date / time on this entity from within the testing code. But is there really no support for such a common need built into the Android testing framework?

Cœur
  • 37,241
  • 25
  • 195
  • 267
theV0ID
  • 4,172
  • 9
  • 35
  • 56
  • The android emulator allows you to meddle with your network settings, so I really doubt that it would prevent you from changing the date from within the emulator itself ... – SvenT23 May 13 '14 at 13:23
  • If you are testing with an emulator, can you try to change the date/time of the host machine? – dacongy May 13 '14 at 13:34
  • I can't find a way to set the system date/time programmatically either. It seems only possible to processes that run as 'system' user according to [this](https://stackoverflow.com/questions/1332269/how-to-set-mobile-system-time-and-date-in-android). You know of a way to run the testing project as 'system' user? – theV0ID May 13 '14 at 13:34
  • I wasn't talking about programmatically :) just start your emulator, go to your settings and go to the date/time settings. Just tested it to be sure, and it has no problems with you doing whatever you want with the date and time, just like your regular phone – SvenT23 May 13 '14 at 13:43

0 Answers0