Skip to content

No way to use Swagwire under JUnit 5 #20

Description

@awood

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions