Skip to content

Support for WireMock default instance #19

Closed
@scordio

Description

@scordio

I'm looking at how to replace spring-cloud-contract-wiremock with wiremock-spring-boot in one of my projects (scordio/spring-batch-notion#25) and I noticed the configuration becomes a little more verbose.

Specifically:

  • @AutoConfigureWireMock(port = 0) is replaced by @EnableWireMock(@ConfigureWireMock(name = "wiremock", property = "wiremock.server.url"))
  • Wherever WireMock static methods like givenThat were used, I must use instead a WireMockServer instance injected via @InjectWireMock("wiremock")

In my use case, I don't need custom configurations or the support of multiple instances per test execution, therefore relying on the WireMock default instance would be enough.

I'd like to propose an enhancement where:

  • The declaration of @EnableWireMock without any additional @ConfigureWireMock sets up the WireMock default instance on a random available port
  • The port would be injected into a wiremock.server.port property, mimicking Spring Could Contract WireMock for some convention over configuration
  • Wiremock static methods work with the default instance and without the need to inject it via @InjectWireMock (although nothing should prevent its usage)

If you agree with the idea, I'll be happy to investigate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions