-
Notifications
You must be signed in to change notification settings - Fork 17
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
Wiremock server not stopping between test classes when @SpyBean used #82
Comments
I think it actually is stopping, but not fast enough: wiremock-spring-boot/src/main/java/org/wiremock/spring/internal/WireMockServerCreator.java Line 107 in 1b42d76
And the annotation triggers a new ApplicationContext. Without it, the same ApplicationContext is re-used. There are 2 problems:
Why do you need to use a static port? |
Just because its the port we would normally use for the service which makes the integration test more realistic instead of switching port. The static port is currently set in our test application.yml and loaded into the service via dependency injection. Previously we were using the stub contract runner with @AutoConfigureWiremock(8141) which worked fine before switching over to wiremock-spring-boot.
Just because its the port we would normally use for the service which makes the integration test more realistic instead of switching port. The static port is currently set in our test application.yml and loaded into the service via dependency injection. Previously we were using the stub contract runner with @AutoConfigureWiremock(8141) which worked fine before switching over to wiremock-spring-boot. |
Proposal
spring boot version: 3.3.7
spring boot test version: 3.3.7
wiremock-spring-boot version: 3.3.0 (tried all newer and older versions too)
Currently mocking one service we call multiple times across different integration tests on the same port.
Once one of the integration tests introduces @SpyBean, there is a change in wiremock behavior in that the wiremock server is not stopped once all the test methods have been executed in the class. Currently this results in a port conflict with the next integration test class which tries to start up wiremock on the same port:
Expectation is wiremock server would use normal behavior with stoping once all test methods in a test class are completed so that the next test class can start another wiremock server up on the same port. I can confirm that without @SpyBean being used that this happens as expected.
Reproduction steps
spring boot version 3.3.7
any wiremock-spring-boot version
Run multiple @SpringBootTest integration test classes (not ran in parallel) that mock the same port with a spring-boot-test @SpyBean in at least one of them:
ServiceA
Integration Test Class 1 example
Integration Test Class 2 example
References
No response
The text was updated successfully, but these errors were encountered: