problem-spring-web icon indicating copy to clipboard operation
problem-spring-web copied to clipboard

Library doesn't work in `@WebMvcTest`

Open remal opened this issue 2 years ago • 0 comments

Description

I'd like to test that my exceptions and handled correctly and application/problem+json response is returned.

For that, I write tests annotated with @WebMvcTest.

Expected Behavior

Auto-configurations from org.zalando:problem-spring-web-autoconfigure are included in the test context.

Actual Behavior

Auto-configurations from org.zalando:problem-spring-web-autoconfigure are NOT included in the test context.

Possible Fix

Copy content of META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports into:

  • META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports - to support @WebMvcTest
  • META-INF/spring/org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebFlux.imports - to support @WebFluxTest

remal avatar May 24 '23 18:05 remal