Trying to mock OffsetDateTime.now() with mockk, but it throws
Missing calls inside every { ... } block
I tried:
staticMockk<OffsetDateTime>().mock().run {
val mockTime = OffsetDateTime.now()
every { OffsetDateTime.now() } returns mockTime
// test
}
Also tried:
mockkStatic(OffsetDateTime::class)
val mockTime = OffsetDateTime.now()
every { OffsetDateTime.now() } returns mockTime
For me it is okay. Please consider using the latest version (1.8.8 or 1.8.8.kotlin13) or if it does not work please report a bug.
Here is my code:
mockkStatic(OffsetDateTime::class)
val date = OffsetDateTime.of(
2012,
10,
10,
10,
10,
10,
10,
ZoneOffset.UTC
)
every {
OffsetDateTime.now()
} returns date
println(OffsetDateTime.now())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With