After upgrading from Spring boot 2.2.2 to 2.3.3 the feign client in tests are not replaced. The mocked bean seems to be instantiated but it does not replace the actual FeignClient provided by the application.
spring-cloud-starter-openfeign version : 2.2.5.RELEASE
spring boot version: 2.3.3.RELEASE
spring version: 5.2.8.RELEASE
I have found the issues related to this saying that is already fixed but for me it doesn't seem to replace the actual FeignClient. https://github.com/spring-cloud/spring-cloud-openfeign/issues/336
https://github.com/spring-cloud/spring-cloud-openfeign/issues/337
@SpringBootTest(classes = [SomeApplication.class], webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = [ApplicationTestConfig])
@ActiveProfiles("test")
@TestExecutionListeners([DependencyInjectionTestExecutionListener, TransactionalTestExecutionListener])
@AutoConfigureMockMvc
abstract class AbstractControllerSpecification extends AbstractSpecification {}
And for the ApplicationTestConfig I have something like this
@EntityScan(basePackages = "somepackage")
@ComponentScan(basePackages = "somepackage")
@IntegrationComponentScan(basePackages = "somepackage")
@Profile("test")
class ApplicationTestConfig {
DetachedMockFactory factory = new DetachedMockFactory()
@Bean
SomeResource someResource() {
factory.Mock(someResource)
}
}
A work-around I have found is to set the FeignClient(primary = false) and it seems to be working properly but I don't think that is a solution.
Any ideas if this is still a problem in 2.3.3?
Comment From: OlgaMaciaszek
Hello, @DoniciMarius. Please provide a minimal, complete, verifiable example that reproduces the issue (preferably as a link to GH project).
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: mark4z
Maybe i will fix it.
Comment From: OlgaMaciaszek
Hi @mark4z , please feel free to submit a PR.
Comment From: mark4z
@OlgaMaciaszek It's fixed on feign 2.2.3.RELEASE, so no need PR anymore.
Comment From: apb12
@OlgaMaciaszek It's fixed on feign 2.2.3.RELEASE, so no need PR anymore.
it does not fix yet, ive got same issue. What spring boot starter we should to use to awoid this issue? You told its fixed on feign 2.2.3, but the guy that started this topic used spring-cloud-starter-openfeign version : 2.2.5.RELEASE So did you go to past and fix it or just lied to us?
Comment From: OlgaMaciaszek
Hello, @apb12, please provide a minimal, complete, verifiable example that reproduces the issue (preferably as a link to GH project).
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.