Cody Engel
10/08/2019, 10:45 PMclearAllMocks and unmockkAll? I have the following test rule and when I used clearAllMocks in the finished function I was seeing some tests failing because a mockkObject wasn’t being cleared. With unmockkAll though it resolved the issue.
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 clearAllMocks over unmockkAll?