Markus Jevring
10/17/2023, 8:33 AM@RegisterExtension
annotation, and I know that my extension's getName()
method is called, but the transform
method is never actually called. I have tried using both a ResponseTransformer
and a ResponseDefinitionTransformer
, just in case there was a difference, and neither works.
I'm using stubFor()
to register the transformer for the stub. I know the stub matches the call, because I can make changes to the stub, and they show up in the test. I also tried using json stubs, with the same transformer name, and that also didn't work.
I'm using WireMock 2.35 in a spring-boot 3 application.
I followed this guide, but with the caveat that that guide uses interfaces that don't exist in my version of WireMock. Presumably because the guide is for a newer version of WireMock.
I'm getting WireMock via org.springframework.cloud:spring-cloud-contract-wiremock
, so I'm not really in a position to upgrade to 3.2.0.
Any idea what I might be missing?@AutoConfigureWireMock(port = 0, stubs = "classpath:/stubs")
Tom
10/17/2023, 9:25 AM@RegisterExtension
is for JUnit extensions rather than WireMock's.
You need to add your transformer via the .extensio s(...)
method on the config object passed to WireMock at startup.Markus Jevring
10/17/2023, 9:44 AMTom
10/17/2023, 10:07 AMWireMockConfiguration
into the test context and add it to this, per this comment:
https://github.com/spring-cloud/spring-cloud-contract/blob/main/spring-cloud-contr[β¦]ingframework/cloud/contract/wiremock/WireMockConfiguration.javaMarkus Jevring
10/17/2023, 10:11 AMWireMockConfiguration
as a bean, but I ran into issues that it didn't pick up whatever other spring magic the auto-configuration does.
However, what did solve it was adding a WireMockConfigurationCustomizer
bean:Tom
10/17/2023, 10:12 AMMarkus Jevring
10/17/2023, 10:13 AMTom
10/17/2023, 10:13 AM