com.ninjasquad.springmockk.MockkContextCustomizerFactory.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of springmockk Show documentation
Show all versions of springmockk Show documentation
MockBean and SpyBean, but for MockK instead of Mockito
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