Issue
How to verify that a top level (static) function was called in a test with MockK?
Simple approach like:
verify { someTopLevelFunction("some text") }
results in io.mockk.MockKException: can't find stub kotlin.Unit
.
Solution
You would mockk the same way you mockk extension functions https://mockk.io/#extension-functions
In practice generally:
mockkStatic(ClassNameWhereFunctionIsLocated::class)
verify {
someTopLevelFunction("some text")
}
Answered By - Murph_Fish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.