-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Configure WebTestClient for @AutoConfigureMockMvc tests #23067
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
Comments
I can see there is already a @BeforeEach
void setUp(@Autowired MockMvc mockMvc) {
webTestClient = MockMvcWebTestClient.bindTo(mockMvc).build();
} 1 note: |
@philwebb Does this mean we can use @AutoConfigureMockRestServiceServer with WebTestClient as well, so internal WebClient/RestTemplate calls can be mocked from the test? If so we could update documentation and also okhttp would not be needed anymore as explained here right? spring-projects/spring-framework#19852 |
Even if it did, we would be missing important parts of the |
Ok, thanks! I thought that the fact WebTestClient supported now MockMVC enabled somehow the use of MockRestServiceServer for internal mocking |
Uh oh!
There was an error while loading. Please reload this page.
Spring Framework recently added
WebTestClient
support for testing Spring MVC applications usingMockMvc
(see spring-projects/spring-framework#19647).Right now, Spring Boot offers two ways to test a web application: using
TestRestTemplate
on a running web server or withMockMvc
(no actual server involved).We should consider
MockMvcTestClient
and how we should update our testing infrastructure and documentation with this new option.The text was updated successfully, but these errors were encountered: