Open bclozel opened 1 month ago
What about using MockMvc, and then check the output stream? Not at the same level of control, but MockMvc is lightweight (no server, nor full Spring config), and tests controllers more fully. In terms of testing items as they come, one at a time, one way or the other, the controller can't stream indefinitely, and has to be notified in some way to stop streaming, which makes it feasible to aggregate and check the response.
As seen in #33722,
SseEmitter
does not currently provide a way to perform assertions on published events for testing purposes. Our own testing infrastructure is leveraging protected methods to configure a test handler - we should consider providing a testing utility for this use case.