Florian Walther (live streaming)
01/10/2022, 1:15 PMadvanceTimeBy
? For example, I'm using a fake timesource so the actual advanced time doesn't matter.hfhbd
01/10/2022, 2:05 PMrunTest {
advanceTimeBy(1.minutes)
}
Florian Walther (live streaming)
01/10/2022, 2:09 PMhfhbd
01/10/2022, 2:11 PMTestScope
with another TimeSource, not the provided one?@Test
@ExperimentalTime
fun testAdvanceTimeSource() = runTest {
val expected = 1.seconds
val actual = testTimeSource.measureTime {
delay(expected) // or advanceTimeBy(1.seconds)
}
assertEquals(expected, actual)
}
Florian Walther (live streaming)
01/11/2022, 11:02 AMtimeSource
? I don't have that available in my codekotlinx-coroutines-test
documentation. Where do I learn about this stuff?elapsedRealtime
in my production code.hfhbd
01/11/2022, 11:09 AMFlorian Walther (live streaming)
01/11/2022, 11:09 AMelapsedNow
hfhbd
01/11/2022, 1:04 PMTimeSource.toTestSystemClock()
.
In tests, delay
is exact.Florian Walther (live streaming)
01/11/2022, 2:08 PMhfhbd
01/11/2022, 2:09 PMFlorian Walther (live streaming)
01/12/2022, 10:44 AMhfhbd
01/12/2022, 3:07 PMLong
, what prevents you from using TestScope.currentTime
? 😄Florian Walther (live streaming)
01/13/2022, 10:52 AM