maciejwalkowiak / wiremock-spring-boot

WireMock Spring Boot drastically simplifies testing HTTP clients in Spring Boot & Junit 5 based integration tests.
MIT License
218 stars 13 forks source link

Injecting Wiremock does not work with JUnit @Nested #20

Open calnighters opened 9 months ago

calnighters commented 9 months ago

When trying to use a global WiremockServer in a test inside a nested test class annotated with @Nested, the test cannot invoke any stubs because the WiremockServer is null. I get the below running in a nested class, but without the nesting then the tests run fine and the wiremock works as expected.

java.lang.NullPointerException: Cannot invoke "com.github.tomakehurst.wiremock.WireMockServer.stubFor(com.github.tomakehurst.wiremock.client.MappingBuilder)" because "this.this$0.graphWiremock" is null

chriseteka commented 7 months ago

Hi @calnighters Can you share your test setup? I've tried to reproduce and I couldn't. Verify if this is still an issue, if so share some snippet. Thank you.