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

com.ninjasquad.springmockk.MockkContextCustomizerFactory.kt Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
package com.ninjasquad.springmockk

import org.springframework.test.context.ContextConfigurationAttributes
import org.springframework.test.context.ContextCustomizer
import org.springframework.test.context.ContextCustomizerFactory

/**
 * A {@link ContextCustomizerFactory} to add MockK support.
 *
 * @author Phillip Webb
 * @author JB Nizet
 */
class MockkContextCustomizerFactory : ContextCustomizerFactory {
    override fun createContextCustomizer(
        testClass: Class<*>,
        configAttributes: List
    ): ContextCustomizer {
        // We gather the explicit mock definitions here since they form part of the
        // MergedContextConfiguration key. Different mocks need to have a different key.
        val parser = DefinitionsParser()
        parser.parse(testClass)
        return MockkContextCustomizer(parser.parsedDefinitions)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy