Hi, I'm trying to use `verify(exactly = 1)` inside...
# mockk
k
Hi, I'm trying to use
verify(exactly = 1)
inside a kotlintest
BehaviorSpec
, but it fails as it doesn't seem to be isolated from my other
Given
scope. Here's a basic example:
Copy code
Given("foo") {
  every { persistentSource.getAccessToken() } returns IO.raiseError(exception)
  When("") {
    [...] Then [...]
  }
}
Given("foo2") {
  every { persistentSource.getAccessToken() } returns IO { smartphonePersistedAccessToken }
  When("") {
    [...]
    Then("") {
      verify(exactly = 1) { persistentSource.getAccessToken() }
    }
  }
}
l
Pinging here from #kotlintest
What you're facing is exactly what you described. The mocks aren't being cleared between tests
What you need to do is either clear them on `afterTest`/`beforeTest or change the isolation mode so that the class is created more than once
To reset the mocks, I think you can use
clearMockks
or similar from #mockk itself
k
I'll check this out, thanks!