in the finished function I was seeing some tests failing because a
mockkObject
wasn’t being cleared. With
unmockkAll
though it resolved the issue.
Copy code
class MockKTestRule(private val target: Any) : TestWatcher() {
override fun starting(description: Description?) {
super.starting(description)
MockKAnnotations.init(target)
}
override fun finished(description: Description?) {
unmockkAll() // clearAllMocks doesn't work for all use cases
super.finished(description)
}
}
But I don’t understand what the difference is? When would I want to use