All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mockk.impl.stub.CommonClearer.kt Maven / Gradle / Ivy

The newest version!
package io.mockk.impl.stub

import io.mockk.MockKGateway
import io.mockk.MockKGateway.Clearer
import io.mockk.impl.log.Logger
import io.mockk.impl.log.SafeToString

class CommonClearer(
    val stubRepository: StubRepository,
    val safeToString: SafeToString
) : Clearer {
    val log = safeToString(Logger())

    override fun clear(mocks: Array, options: MockKGateway.ClearOptions) {
        log.debug { "Clearing ${mocks.contentToString()} mocks $options" }
        for (mock in mocks) {
            stubRepository.stubFor(mock).clear(options)
        }
    }

    override fun clearAll(options: MockKGateway.ClearOptions) {
        stubRepository.allStubs.forEach {
            it.clear(options)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy