Smarty Blog - September 2015

Testing in Go by example: Part 5Arrow Icon
An elegant and effective strategy for dealing with time in unit tests
September 15, 2015 - For this installment of the Testing in Go series I'll share a really nifty way to deal with time in your unit tests. When the behavior you are testing depends on the current time it can be tricky to assert on the results because the current time is a moving target. So, usually we end up resorting to approximations in our assertions that, while functional, always bother me a bit. In some cases, depending directly on the system's current time prevents acceptable test coverage. Consider this trivial example, which defines a calendar service with a method that identifies the current quarter of the current calendar year: File: calendar.
View Blog Tags

The leader in location data intelligence

Ready to get started?