Hi! Please tell is there a way to verify that no o...
# mockk
m
Hi! Please tell is there a way to verify that no one mock was called? something like
Copy code
verify { getAllMocks() wasNot called }
j
there is a
confirmVerified(…)
method, not sure if that’s what you’re looking for
m
it requires explicit list of mocks also.
I would like to not specify mocks list by myself, leaving it to the library, Like with
clearAllMocks/unmockAll
j
Not sure (please check experimentally) but judging by the source code, providing empty list verifies all mocks.
also there’s
@MockKExtension.ConfirmVerification
which does that verification for you
m
Yes you are right, thank you! here it source code
Copy code
override fun acknowledgeVerified() {
        stubRepo.allStubs.forEach { acknowledgeVerificationHelper(it) }
    }

    override fun acknowledgeVerified(mock: Any) {
        val stub = stubRepo.stubFor(mock)
        acknowledgeVerificationHelper(stub)
    }