Join Slack
Powered by
Hello, is there a way to set the system clock in t...
# kotlinx-datetime
d
Daniel Weidensdörfer
07/08/2023, 8:31 AM
Hello, is there a way to set the system clock in tests to mock getTimeMillis()?
h
hfhbd
07/08/2023, 8:50 AM
You should pass your own Clock.
d
Daniel Weidensdörfer
07/08/2023, 9:25 AM
Yeah, I know, wrote a wrapper now
h
hfhbd
07/08/2023, 9:27 AM
What do you mean with wrapper? There is TimeSource to measure times (Duration) and Clock for walltime and Date/TimeeZone support
d
Daniel Weidensdörfer
07/08/2023, 9:27 AM
A wrapper around getTimeMillis, so I can mock it
h
hfhbd
07/08/2023, 9:28 AM
Just don’t use getTimeMillie but measureTime with your mocked TimeSource.
3
Views
Open in Slack
Previous
Next