Wednesday 8 July 2009

Testing Times - Freezing Times

I have found many tests that want to set a time in a class and then test that that object has the correct time set.

Often these tests will pass when run locally as unit tests but either fail as integration tests which tend to be slower or fail when run on a heavily loaded build server.

I came across the solution on Mark Needham's Blog making use of a joda-time.

There appears to be may other usefull classes such as LocalDate, a class that just holds the date, yep the bit that says 25/12/2009 with no time representation, ie just a date !!!

No comments: