aarkling
04/11/2023, 1:46 PMaarkling
04/11/2023, 1:46 PMCLOVIS
04/11/2023, 2:08 PMClock
to get the current time, instead of hard-coding it. Then, at the start of your test, you can trivially create a clock that reads the virtual time.CLOVIS
04/11/2023, 2:09 PMephemient
04/11/2023, 6:51 PMsuspend fun doStuff(timeSource: TimeSource = TimeSource.Monotonic) {
...
}
// production code
doStuff()
// test code
runTest {
doStuff(timeSource = testScheduler.timeSource)
}
aarkling
04/11/2023, 7:00 PMCLOVIS
04/11/2023, 7:00 PMcontext
will be for, but it's not ready yet.aarkling
04/11/2023, 7:01 PMCLOVIS
04/11/2023, 7:01 PMephemient
04/11/2023, 7:01 PMCLOVIS
04/11/2023, 7:02 PMephemient
04/11/2023, 7:03 PMCLOVIS
04/11/2023, 7:04 PMaarkling
04/11/2023, 11:02 PM