-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@WireMockTest usually requires @DirtiesContext #42
Comments
look at ContextCustomizer from spring framework 4.3 |
Hi, The problem I'm struggling with right now, how to force |
AFAIR we had this in place. If you use |
@poznachowski thanks for the link BTW. Important part here is that we don't let wiremock choose a random port, but we probe a free port and save this in a spring property, which later gets assigned as fixed port to wiremock. This property is the sauce for further configuration of your FeignClient or other services. |
np :) I think that I don't see the difference. In my solution I also look up for a free port, starts Wiremock with that, and sets that all Feign clients connects to it. Does that behaviour differs from yours? With using spel expression, that would require providing in every test with Wiremock Feign client name and I wanted to avoid that and come up with generic solution for all Feign clients available. |
hm. You might be overengineering things. From my point of view the test should know which feign client it needs to wire to wiremock. Not all FeignClients on the classpath should - only the one you're interested in testing. @UlfS @jensfischerhh correct me if I'm wrong, but what we're doing is something along the lines of this: SomeFeignClient.class @FeignClient(url="${someFeignClient.baseUri}")
interface SomeFeignClient {} .. and application-test.yml
|
.. haven't touched spring code for a while, so i feel a bit rusty... ;-) |
@otrosien Yup, that's what we're doing, but I think we are using the |
@UlfS actually both should work. In |
all our wiremock tests ended up being ignored, because they somehow pollute spring context and plain DirtiesContext is not enough. The only thing that helps is applying DirtiesContext before every test class (even those that have nothing to do with wiremock). Just not worth the trouble. |
Due to the fact that the wiremock test execution listener adds a new property source that is unknown when we started the application context from a different test. So we need to restart the application context, in order to access our wiremock.port property. We need to find a better approach.
The text was updated successfully, but these errors were encountered: