{"record":{"id":"ff57aaaed6604100","repo":"OpenFeign/feign","slug":"wanted-s-but-never-invoked-got-s","errorCode":null,"errorMessage":"Wanted: '%s' but never invoked! Got: %s","messagePattern":"Wanted: '(.+?)' but never invoked! Got: (.+?)","errorType":"exception","errorClass":"VerificationAssertionError","httpStatus":null,"severity":"error","filePath":"mock/src/main/java/feign/mock/MockClient.java","lineNumber":257,"sourceCode":"  }\n\n  public Request verifyOne(RequestKey requestKey) {\n    return verifyTimes(requestKey, 1).get(0);\n  }\n\n  public List<Request> verifyTimes(final HttpMethod method, final String url, final int times) {\n    if (times < 0) {\n      throw new IllegalArgumentException(\"times must be a non negative number\");\n    }\n\n    if (times == 0) {\n      verifyNever(method, url);\n      return Collections.emptyList();\n    }\n\n    RequestKey requestKey = RequestKey.builder(method, url).build();\n    if (!requests.containsKey(requestKey)) {\n      throw new VerificationAssertionError(\n          \"Wanted: '%s' but never invoked! Got: %s\", requestKey, requests.keySet());\n    }\n\n    List<Request> result = requests.get(requestKey);\n    if (result.size() != times) {\n      throw new VerificationAssertionError(\n          \"Wanted: '%s' to be invoked: '%s' times but got: '%s'!\",\n          requestKey, times, result.size());\n    }\n\n    return result;\n  }\n\n  public List<Request> verifyTimes(RequestKey requestKey, final int times) {\n    if (times < 0) {\n      throw new IllegalArgumentException(\"times must be a non negative number\");\n    }\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/mock/src/main/java/feign/mock/MockClient.java#L239-L275","documentation":"verifyTimes(HttpMethod, String, times) builds a RequestKey from method and url and looks it up in the recorded requests map. If no request with exactly that method and url was ever recorded, a VerificationAssertionError is thrown listing the keys that were actually invoked. This is a 'wanted invocation never happened' verification failure.","triggerScenarios":"mockClient.verifyTimes(method, url, n>0) (or verifyOne) where requests map contains no entry whose RequestKey equals the built method/url key.","commonSituations":"Typo or wrong path in the verify call; request was never sent because an earlier mock/test failed; request used different query string or base URL than the verify key; sequential mode aborted before sending it.","solutions":["Ensure the request was actually sent before verifying (check earlier test steps/exceptions)","Make the method and url in verifyTimes exactly match what the client sends (path, query params)","Inspect the 'Got:' list in the message to find the recorded key and use it","If the request should not happen at all, use verifyNever instead"],"exampleFix":"// before\nmockClient.verifyTimes(HttpMethod.GET, \"/api/users\", 1); // never invoked\n// after\nmockClient.verifyTimes(HttpMethod.GET, \"/api/v1/users\", 1); // match actual request","handlingStrategy":"try-catch","validationCode":"// Check the key exists before verifying:\nRequestKey key = RequestKey.builder(method, url).build();\nboolean invoked = mockClient.verifyTimes(method, url, 1) != null; // or track via verifyNever first\nif (!invoked) { /* handle */ }","typeGuard":null,"tryCatchPattern":"try {\n  mockClient.verifyOne(HttpMethod.GET, \"/api/users\");\n} catch (VerificationAssertionError e) {\n  fail(\"Expected request never invoked. Recorded: \" + e.getMessage());\n}","preventionTips":["Copy the exact method/url from the client contract into verify calls","Always send the request before verifying it","Read the 'Got:' list in the message to align your key"],"tags":["mock","test","verification","never-invoked"],"backgroundTag":"record-not-found","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"}