-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Add overload for MockRestServiceServer.verify with a timeout #22618
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
@rstoyanchev, what do you think about adding this? |
How would this work specifically, check if expectations > 0 and if so wait for up to the specified time, but otherwise fail early in case of failures? |
My mental model of In the asynchronous case, it would loop, checking for 4 possibilities:
In essence, something like this but more polished: success = false;
while (elapsed() < timeout && !success) {
try {
verify();
success = true;
} catch (Exception e) {
// ignore failed verifications
}
}
if (!success) { throw TimeoutException(); } |
Expectations are ordered by default but that can be turned off. In any case, regardless of the |
The goal is to verify that the expected interactions occur up to the given timeout.
This is useful for testing asynchronous flows in event-driven services, similar to the testing support in Spring Amqp.
Sample code:
The text was updated successfully, but these errors were encountered: