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 PMFlorian Walther (live streaming)
01/10/2022, 2:09 PMFlorian Walther (live streaming)
01/10/2022, 2:09 PMhfhbd
01/10/2022, 2:11 PMTestScope
with another TimeSource, not the provided one?hfhbd
01/10/2022, 2:16 PM@Test
@ExperimentalTime
fun testAdvanceTimeSource() = runTest {
val expected = 1.seconds
val actual = testTimeSource.measureTime {
delay(expected) // or advanceTimeBy(1.seconds)
}
assertEquals(expected, actual)
}
hfhbd
01/10/2022, 2:20 PMFlorian Walther (live streaming)
01/11/2022, 11:02 AMtimeSource
? I don't have that available in my codeFlorian Walther (live streaming)
01/11/2022, 11:03 AMFlorian Walther (live streaming)
01/11/2022, 11:05 AMkotlinx-coroutines-test
documentation. Where do I learn about this stuff?Florian Walther (live streaming)
01/11/2022, 11:08 AMelapsedRealtime
in my production code.hfhbd
01/11/2022, 11:09 AMFlorian Walther (live streaming)
01/11/2022, 11:09 AMFlorian Walther (live streaming)
01/11/2022, 11:09 AMFlorian Walther (live streaming)
01/11/2022, 11:13 AMFlorian Walther (live streaming)
01/11/2022, 11:46 AMelapsedNow
hfhbd
01/11/2022, 1:04 PMTimeSource.toTestSystemClock()
.
In tests, delay
is exact.Florian Walther (live streaming)
01/11/2022, 2:08 PMFlorian Walther (live streaming)
01/11/2022, 2:08 PMFlorian Walther (live streaming)
01/11/2022, 2:08 PMFlorian Walther (live streaming)
01/11/2022, 2:09 PMFlorian Walther (live streaming)
01/11/2022, 2:09 PMhfhbd
01/11/2022, 2:09 PMFlorian Walther (live streaming)
01/12/2022, 10:44 AMFlorian Walther (live streaming)
01/12/2022, 10:45 AMhfhbd
01/12/2022, 3:07 PMLong
, what prevents you from using TestScope.currentTime
? 😄Florian Walther (live streaming)
01/13/2022, 10:52 AMFlorian Walther (live streaming)
01/13/2022, 10:53 AM