Skip to content

WebTestClient: Add AutoConfiguration for MockMvcWebTestClient? #897

Closed as not planned
@eiswind

Description

@eiswind

I just stumbled accross this when moving a test from MockMvc to MockMvcWebTestClient.

As far as I could see the AutoConfigureRestDocs for WebTestClient only works in a reactive web app. It's not a big deal, as I could workaround like

@ExtendWith(RestDocumentationExtension.class)
@WebMvcTest(CustomerApiController.class)
class CustomerApiControllerTest {

    private WebTestClient client;

    @Autowired
    MockMvc mockMvc;

    @BeforeEach
    public void setUp(RestDocumentationContextProvider restDocumentation) {
        this.client = MockMvcWebTestClient.bindTo(mockMvc).baseUrl("http://localhost")
                .filter(documentationConfiguration(restDocumentation))
                .build();
    }

Can you imagine providing something like this with the AutoConfiguration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions