Injecting Clock in Java
Post on 09-May-2015
259 Views
Preview:
DESCRIPTION
Transcript
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
Injecting Clock
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
Injecting Clock is about
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
Injecting Clock is about
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
Injecting Clock is about
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
Injecting Clock is about
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
Injecting Clock is about
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
Why do we care?
• You can write tests that do not depend on when they are run – Ward against Daylight Savings transition
• You can write tests for specific timing conditions – Test these “after NN hours” rules
• Offers another way of controlling timezone to be used by some code – More selective than default time zone
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
How does it work?
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
How does it work?
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
How does it work?
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
How does it work?
© 2014 RichRelevance, Inc. All Rights Reserved. Confidential.
How do I test? • Inject a clock explicitly
– Mocked – From a Clock factory
top related