Simple extension to inject ready-to-use wiremock server to JUnit5 test
- Add dependency
ru.lanwen.wiremock:wiremock-junit5:${wiremock-junit5.version}
- Create JUnit5 test:
@ExtendWith({
WiremockResolver.class,
WiremockUriResolver.class
})
class WiremockJUnit5Test {
@Test
void shouldInjectWiremock(@Wiremock WireMockServer server, @WiremockUri String uri) {
customize(server); // your setup
SomeApiClient api = SomeApiClient.connect(uri);
Response response = api.call();
assertThat(response.headers(), hasSize(1));
}
}
With ru.lanwen.wiremock.config.WiremockCustomizer
and ru.lanwen.wiremock.config.WiremockConfigFactory
you can reuse logic of initial setup.
Please look into test for example.
- v1.0.1
->
M4 - v1.1.0
->
RC2 - v1.1.1
->
GA