java - How to override the current system date within junits -


i want curent system date overriden junits.please help.

one technique use not call usual date/calendar factory methods/constructors, nor system.getcurrenttimemillis. instead inject date/time "factory," namely interface methods whatever need in way of getting system time.

then during test inject instance control directly (hard-coding time, or storing in file, depending on i'm testing). otherwise inject implementation makes appropriate real calls system.

it's not work sounds, , makes testing time/date-sensitive code straightforward.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -