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

Emil Kantis

06/01/2021, 8:45 PM
Hi, I just ran into a very tricky problem. I had a mock of an extension function from a test which ended up recording millions of method calls, which ultimately led the test execution to hang completely. In my case I had also forgot to clear mocks at one point, which made the hang happen in a completely different test which didn't make it obvious that the problem was related to a mock at all. Posting here to get some input before possibly filing an issue on octocat I think it would be reasonable that mockk had a (configurable) cap of the amount of recorded invocations, and any further calls throws an exception. The cap should be sufficiently low to not cause an extreme slowdown of tests before throwing exception.
m

Mattia Tommasone

06/01/2021, 8:47 PM
that’s indeed a tricky problem: i think it’s pretty rare (it’s actually the first time i’ve seen somebody run into this issue), but it may be ok to put a cap on the number of recorded invocations
e

Emil Kantis

06/01/2021, 9:10 PM
I'll try to get some numbers on when it becomes a problem and a reproduction case 🙂
m

Mattia Tommasone

06/01/2021, 9:12 PM
that’d be great!
e

Emil Kantis

06/01/2021, 9:59 PM
https://github.com/Kantis/mockk-repro Seems like between 130k - 140k invocations is enough to cause issues.. You can run test with
./gradlew test -i
to see amount of invocations before it just seem to stop..
m

Mattia Tommasone

06/03/2021, 6:47 AM
thanks!
2 Views