is this answer still valid? <https://stackoverflow...
# mockk
p
is this answer still valid? https://stackoverflow.com/a/49819729
o
Yep, should work
p
Seems like
mockkStatic
is not thread safe? I run my tests in parallel and use
mockkStatic
of the same class in multiple different classes.
Since
mockkStatic
always unmocks the class first, if the other test is currently running it will briefly be able to access the unmocked class.
o
Yes, some of mockk parts weirdly behaving with parallel tests
p
trying this now:
Copy code
synchronized(UtilClass::class) {
    mockkStatic(UtilClass::class)
    every { UtilClass.staticMethod(any()) } returns 42
}
o
Might work :-)
You can just wrap only mockkStatic probably, not code setting beheviour
p
didn’t help unfortunately 😕
odd
o
Ah it wont
It is not possible to do actually
Coz state is flobal
Global
p
ok, i will have to find another way then, thank you
o
I.e. it is not possible to run parallel tests
Coz in the middle of one test state is being reset. You need to wrap whole tests then