A Real World Tip for Implementing Enterprise Applications

I thought I’d share a technique I’ve found very useful for any application of significant size with a need for automated testing.  A lot of transaction processing tasks are time sensitive, particularly in the financial or insurance domains.

This can make automated testing brittle or even impossible while your application directly acquires the current time or date from a system clock.  The tip is to implement an application clock abstraction which is always used by your application for obtaining the current date and time.  Thus in any testing, your application clock can be reliably used to simulate any arbitrary time and date repeatably.  It’s a simple but invaluable pattern making test results repeatable and consistent for years if necessary.

This pattern is really simple to implement and is even relevant for database only operations as the same pattern can be applied there too.

It’s usually worth insuring your application clock can only simulate a date and time when in development environments. It would be nasty to have a production system accidentally start using test values for time and date.

  1. Leave a comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: