15 Min System.getCurrentMillis()
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,547
On Slideshare
1,539
From Embeds
8
Number of Embeds
2

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 8

http://www.slideee.com 5
http://www.slideshare.net 3

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 15 min. System. getCurrentMillis()
  • 2. Problems System is static hard to mock  time/duration is unpredictable when is now how long does it take (to run a test)  we can introduce an error margin is it big enough ...
  • 3. Solution Don't use System.getCurrentMillis() for Data use Data: timestamps, duration (e.g. Joda Time) objects are better then primitives for Services/Beans IClock injected interface ActiveClock: production (thin wrapper) StoppedClock: test startTimestamp tick()/advance()  
  • 4. Similar/useful project  AutoBoundary                                HAPPY CODE READING