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

Not working for Nested test classes #10

Closed sickan90 closed 10 months ago

sickan90 commented 11 months ago

First off, great lib! Thanks!

I'm using @Nested for some of my test classes, but the this lib does not seems to handle it very well:

@EnableWireMock({
        @ConfigureWireMock(name = "external-api", property = "application.external-api.base-url")
})
public class ExternalServiceTest extends IntegrationTest {
    @InjectWireMock("external-api")
    WireMockServer externalApiMock;

    @Nested
    @DisplayName("Test Something")
    public class TestSomething {
        @Test
        public void test1() {
            externalApiMock.stubFor(post(urlPathEqualTo("/test")).willReturn(ok())); // Throws a NullPointerException
        }
    }
}

However moving the annotation to the nested class works fine. So, not a blocker. However, it would be nice if this worked with nested classes in the example above.

maciejwalkowiak commented 10 months ago

Thanks @sickan90 for reporting! It is fixed in 1.0.2, that should appear in Maven Central in few hours.