~/talk

Strategies for Dealing with Date and Time in Test and Production Code

Talkat JDD 2023 · 2023-10-24..10-25· [testing, web-platform]
links:none on file
slides:none on file

Shows that time is a hidden dependency and replaces hacks like sleeps, reflection and manual clock changes with explicit java.time Clock injection, fixed clocks for unit tests and a mutable Clock bean for Spring integration tests, plus a TestExecutionListener to reset state. Demonstrates code on GitHub, uses Awaitility for external asynchronous waits, and enforces the rule with an ArchUnit test that fails builds when Instant.now/LocalDate.now are called directly, producing deterministic, fast tests.

AI-written summary · about

  1. 0:00Introduction to talk
  2. 2:58Date creation in code
  3. 7:19Problems with system clock
  4. 13:05Introducing Clock dependency
  5. 18:41Production code with Clock
  6. 19:46Fast tests with mutable clock
  7. 26:17Slow tests with Spring
  8. 32:24Enforcing Clock usage
  9. 35:20Waiting for async operations
  10. 39:14ArchUnit demo and summary
  11. 41:08Final advice and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.