This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Framework 6.2.1!

Streaming Responses

You can use WebTestClient to test streaming responses such as Server-Sent Events. However, MockMvcWebTestClient doesn’t support infinite streams because there is no way to cancel the server stream from the client side. To test infinite streams, you’ll need to bind to a running server, or when using Spring Boot, test with a running server.

MockMvcWebTestClient does support asynchronous responses, and even streaming responses. The limitation is that it can’t influence the server to stop, and therefore the server must finish writing the response on its own.