Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebTestClient: Add AutoConfiguration for MockMvcWebTestClient? #897

Closed
eiswind opened this issue Oct 17, 2023 · 2 comments
Closed

WebTestClient: Add AutoConfiguration for MockMvcWebTestClient? #897

eiswind opened this issue Oct 17, 2023 · 2 comments

Comments

@eiswind
Copy link

eiswind commented Oct 17, 2023

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?

@wilkinsona
Copy link
Member

Duplicates #691 and spring-projects/spring-boot#35348.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2023
@eiswind
Copy link
Author

eiswind commented Oct 17, 2023

@wilkinsona Thanks for pointing me there. As for my use case this workaround seems to do what I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants