OpenFeign/feign · error · VerificationAssertionError
More executions were expected
Error message
More executions were expected
What it means
verifyStatus() is meant to be called in an @After method for sequential MockClient mode. If the response iterator was never opened while responses were queued, or still has unplayed entries, a VerificationAssertionError 'More executions were expected' is thrown because not all recorded responses were consumed by actual requests.
Solutions
- Invoke the Feign client methods that consume all enqueued responses
- Remove extra mockClient.add(...) entries that no request consumes
- Check for exceptions swallowed/ignored earlier that stopped the request sequence
- Ensure the sequential mock (imitateSequential) is actually wired as the client; a plain imitate() mock never opens the iterator
Example fix
// before mockClient.imitateSequential(); mockClient.add(key1, resp1); mockClient.add(key2, resp2); // test only calls request 1 -> verifyStatus fails // after client.first(); client.second(); // consume both queued responses
Defensive patterns
Strategy: validation
Validate before calling
// After the test body, before/inside @After:
if (mockClient.verifyStatus()) { /* API returns void; wrap: */ }
// Pattern: track expected calls yourself
int queuedResponses = 2;
int actualCalls = countClientCalls();
if (actualCalls < queuedResponses) {
throw new IllegalStateException("Not all mocked sequential responses were consumed");
} Prevention
- Always register verifyStatus() in an @After method when using imitateSequential()
- Enqueue exactly as many responses as requests the test will make
- Make sure the sequential mock client is actually attached to the Feign target under test
When it happens
Trigger: Using MockClient.imitateSequential() and finishing the test while queued responses remain: the Feign client was never called, was called fewer times than enqueued, or the mock was never executed (responseIterator == null with non-empty responses).
Common situations: Forgot to call the client method in the test; early exception aborted the test before all requests were made; enqueued more responses than the code issues; verifyStatus() missing from @After so residual state goes unnoticed in other tests.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- Expected: , but was
- times must be a non negative number
- Wanted: ' ' but never invoked! Got
- Wanted: ' ' to be invoked: ' ' times but got: ' '!
- Do not wanted: ' ' but was invoked!
AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10).
Data as JSON: /api/errors/a0efd146ce1d2d90.
Report an issue: GitHub.
Appendix: source
Thrown at mock/src/main/java/feign/mock/MockClient.java:330
}
}
}
/**
* To be called in an @After method:
*
* <pre>
* @After
* public void tearDown() {
* mockClient.verifyStatus();
* }
* </pre>
*/
public void verifyStatus() {
if (sequential) {
boolean unopenedIterator = responseIterator == null && !responses.isEmpty();
if (unopenedIterator || responseIterator.hasNext()) {
throw new VerificationAssertionError("More executions were expected");
}
}
}
public void resetRequests() {
requests.clear();
}
}
View on GitHub (pinned to e2a1e27560)