maciejwalkowiak / wiremock-spring-boot

WireMock Spring Boot drastically simplifies testing HTTP clients in Spring Boot & Junit 5 based integration tests.
MIT License
218 stars 13 forks source link

Add support for injections the other way around #33

Open netmikey opened 4 months ago

netmikey commented 4 months ago

Hi, thanks for this project as it looks like it can make handling WireMock within Spring Boot tests much easier!

We have a somewhat different use-case: we use JUnit5 to write and run "blackbox integration-style" tests. We need to use a static well-defined port for WireMock but we allow overriding it via Spring Property. We'd like to be able to use an existing SpringBoot Property to configure the WireMock Port.

We looked into using a WireMockConfigurationCustomizer to set the port, but this doesn't get the Spring Context passed into it as far as we could tell.

As a side note: The system under test runs in a different JVM, so our Spring Context only contains Test utilities. As such, it would not be a problem (it would even be preferable) for us to actually have WireMock be a first-class @Bean citizen within the Spring Context used by our tests. This way we could inject configuration properties into it like any other bean.