{"record":{"id":"a0efd146ce1d2d90","repo":"OpenFeign/feign","slug":"more-executions-were-expected","errorCode":null,"errorMessage":"More executions were expected","messagePattern":"More executions were expected","errorType":"exception","errorClass":"VerificationAssertionError","httpStatus":null,"severity":"error","filePath":"mock/src/main/java/feign/mock/MockClient.java","lineNumber":330,"sourceCode":"      }\n    }\n  }\n\n  /**\n   * To be called in an &#64;After method:\n   *\n   * <pre>\n   * &#64;After\n   * public void tearDown() {\n   *   mockClient.verifyStatus();\n   * }\n   * </pre>\n   */\n  public void verifyStatus() {\n    if (sequential) {\n      boolean unopenedIterator = responseIterator == null && !responses.isEmpty();\n      if (unopenedIterator || responseIterator.hasNext()) {\n        throw new VerificationAssertionError(\"More executions were expected\");\n      }\n    }\n  }\n\n  public void resetRequests() {\n    requests.clear();\n  }\n}\n","sourceCodeStart":312,"sourceCodeEnd":339,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/mock/src/main/java/feign/mock/MockClient.java#L312-L339","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nmockClient.imitateSequential();\nmockClient.add(key1, resp1);\nmockClient.add(key2, resp2);\n// test only calls request 1 -> verifyStatus fails\n// after\nclient.first();\nclient.second(); // consume both queued responses","handlingStrategy":"validation","validationCode":"// After the test body, before/inside @After:\nif (mockClient.verifyStatus()) { /* API returns void; wrap: */ }\n// Pattern: track expected calls yourself\nint queuedResponses = 2;\nint actualCalls = countClientCalls();\nif (actualCalls < queuedResponses) {\n  throw new IllegalStateException(\"Not all mocked sequential responses were consumed\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["mock","test","sequential","unused-stub"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}