java - Time dependent unit tests -


i need test function result depend on current time (using joda time's isbeforenow()).

    public boolean isavailable() {     return (this.somedate.isbeforenow()); } 

is possible stub/mock out system time mockito can reliably test function?

joda time supports setting "fake" current time through setcurrentmillisfixed , setcurrentmillisoffset methods of datetimeutils class.

see http://joda-time.sourceforge.net/api-release/org/joda/time/datetimeutils.html


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -