Perhaps this is more of a mockk question, but I've...
# kotest
r
Perhaps this is more of a mockk question, but I've noticed that records from mocks and spys tend to bleed over between tests, even with
confirmVerified
or
unmockX()
between cases. ­čžÁ
For example, given the following contrived example, verifySequence will fail
foo2
because both
service.useSomething(mock, ...)
and
service.useSomething2(mock, ...)
get recorded.
Copy code
val mock = mockk<Something>()
describe("foo") {
  it("foo1") {
     ...
     service.useSomething(mock, ...)

     coVerifySequence {
       service.useSomething(mock, ...)
     }
  }
  it("foo2" {
     ...
     service.useSomething2(mock, ...)

     coVerifySequence {
       service.useSomething2(mock, ...)
     }
  }
}
Copy code
Verification failed: number of calls happened not matching exact number of verification sequence
java.lang.AssertionError: Verification failed: number of calls happened not matching exact number of verification sequence
...
Calls:
1) service.useSomething1(mock, ...)
2) +service.useSomething2(mock, ...)
l
That's because the default isolation mode is creating the Spec only once
One thing you can do is change your isolationMode to
InstancePerTest
It will ensure it will be reseted every instance