Closed
Description
I have migrated https://spring.io/guides/tutorials/spring-boot-kotlin/ to Spring Boot 2.2.0.RELEASE
and updated it to leverage immutable configuration properties. As discussed with @snicoll, @ConfigurationProperties
are not scanned by default in test slices, so I have to add to my @WebMvcTest
test either @EnableConfigurationProperties(BlogProperties::class)
or mock BlogProperties
bean.
My test works with @EnableConfigurationProperties(BlogProperties::class)
but fails if I try to mockk BlogProperties
bean (in my case with @MockkBean
from https://github.com/Ninja-Squad/springmockk) with following error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.example.blog.BlogProperties#0': @EnableConfigurationProperties or @ConfigurationPropertiesScan must be used to add @ConstructorBinding type com.example.blog.BlogProperties