Closed harluss closed 1 year ago
Solution I was looking for was to use SimpleDiscoveryClient, which allowed me to stick with one implementation of the FeignClient mentioned above:
spring:
config:
activate:
on-profile: test
cloud:
discovery:
client:
simple:
instances:
hangar[0]:
uri: http://localhost:${wiremock.server.port:0}
eureka:
client:
enabled: false
Hi, I have a
FeignClient
I use with Eureka Service:Works wonders live but I can't find any information on how to mock/assign an URL for it for Integration Tests with Eureka Service disabled (
enabled: false
)? When I setup WireMock and try to run the test I get this error:If I add
url = "${feign.clients.hangar.url}"
to the Feign annotation and set matching value in test profile inapplication.yml
tests work, but when Eureka is enabled in "prod" the app crashes on startup.It seems like something simple, yet I can't find any information on how to do it. How to provide URL for each client with Eureka disabled without adding the
url
property in the annotation? Or how to overwrite theurl
property inapplication.yml
with values from enabled Eureka, something like `${eureka.whatever.url}?I use
spring-cloud-starter-openfeign
,spring-cloud-starter-netflix-eureka-client
andspring-cloud-contract-wiremock
(mocks) withspring-cloud-dependencies
version2021.0.5
.I guess I could manually create 2 beans or 2 different interfaces extending base one for each client and activate one in prod and other one in tests, that I would prefer to have one implementation and just change config values based on profile. Is that even possible?
Update: By Integration Tests I don't mean just testing the client itself but the whole app - send request to the app, app does it's logic and uses Feign client to hit other microservices (this is the part I'm trying to address here).
I would greatly appreciate any help with this.