https://kotlinlang.org logo
#mockk
Title
# mockk
p

poohbar

10/30/2019, 1:28 PM
Copy code
@Before
fun setup() {

val instant = Instant.ofEpochMilli(1572400000000)
mockkStatic(Instant::class) {
    every { Instant.now() } returns instant
}

}
d

Dias

10/30/2019, 2:22 PM
you can look at the implementation of mockkStatic. You can see that with lambda it uses try finally block and unmocks it
if you use it this way
you can use it without lambda block and it will not unmock
3 Views