JUnit 5 does not use Rules. Instead there is a WireMockExtension that exposes a WireMockRuntimeInfo instance to test methods. WireMockRuntimeInfo doesn't expose the WiremockServer (although it does have a pointer to an instance in a private field); only an instance of WireMock is available. I looked through the RemoteOperation.kt file and it looks like most of the methods being used on the WireMockServer instance are methods that WireMockServer just delegates directly to its internal instance of WireMock. For example
public class WireMockServer implements Container, Stubbing, Admin {
[...]
protected final WireMock client;
[...]
@Override
public StubMapping givenThat(MappingBuilder mappingBuilder) {
return client.register(mappingBuilder);
}
@Override
public void verify(RequestPatternBuilder requestPatternBuilder) {
client.verifyThat(requestPatternBuilder);
}
I don't really have any good suggestions here though. I suppose the .wiremock builder call could be made to take a WireMock instead of WireMockServer and a .wiremockServer builder method added. That breaks compatibility though. Another method .wiremockInstance() could be added, but that leads to some confusing semantics between .wiremock() and .wiremockInstance().
JUnit 5 does not use
Rules. Instead there is a WireMockExtension that exposes aWireMockRuntimeInfoinstance to test methods.WireMockRuntimeInfodoesn't expose theWiremockServer(although it does have a pointer to an instance in a private field); only an instance ofWireMockis available. I looked through theRemoteOperation.ktfile and it looks like most of the methods being used on theWireMockServerinstance are methods thatWireMockServerjust delegates directly to its internal instance ofWireMock. For exampleI don't really have any good suggestions here though. I suppose the
.wiremockbuilder call could be made to take aWireMockinstead ofWireMockServerand a.wiremockServerbuilder method added. That breaks compatibility though. Another method.wiremockInstance()could be added, but that leads to some confusing semantics between.wiremock()and.wiremockInstance().