{"id":9939,"date":"2023-03-16T10:15:27","date_gmt":"2023-03-16T02:15:27","guid":{"rendered":"http:\/\/123.57.164.21\/?p=9939"},"modified":"2023-03-16T10:15:27","modified_gmt":"2023-03-16T02:15:27","slug":"mockito%e6%ba%90%e7%a0%81%e6%b5%85%e6%9e%90-%e6%a0%b8%e5%bf%83%e9%80%bb%e8%be%91","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=9939","title":{"rendered":"Mockito\u6e90\u7801\u6d45\u6790\u2014\u2014\u6838\u5fc3\u903b\u8f91"},"content":{"rendered":"\n<p><strong>\u4e00\u3001<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=Mockito&amp;spm=1001.2101.3001.7020\" target=\"_blank\">Mockito<\/a>\u6e90\u7801\u903b\u8f91\u7b80\u4ecb<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Mockito\u662f\u4e00\u4e2aMock\u6846\u67b6\uff0c\u8ba9\u4f60\u7528\u7b80\u5355\u5e72\u51c0\u7684API\u5199\u6f02\u4eae\u7684\u6d4b\u8bd5\u4ee3\u7801\u3002Mockito\u901a\u8fc7ByteBuddy\u52a8\u6001\u5b57\u8282\u7801\u751f\u6210\u6280\u672f\u751f\u6210mock\u7c7b\u578b\uff08\u4ee3\u7406\u7c7b\uff09\uff0c\u9ed8\u8ba4\u901a\u8fc7objenesis\u6846\u67b6\u751f\u6210mock\u7c7b\u578b\u7684\u5bf9\u8c61\u5b9e\u4f8b\uff0c\u6765\u5b9e\u73b0\u76ee\u6807\u65b9\u6cd5\u7684\u4ee3\u7406\u529f\u80fd\uff0c\u6700\u7ec8\u5b9e\u73b0\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u884c\u4e3a\u3002<\/p>\n\n\n\n<p><br>\u751f\u6210\u7684\u4ee3\u7406\u7c7b\u662f\u88ab\u4ee3\u7406\u7c7b\u7684\u5b50\u7c7b\uff0c\u5176\u91cd\u5199\u4e86\u7236\u7c7b\u7684\u65b9\u6cd5\uff0c\u6bcf\u4e2a\u65b9\u6cd5\u90fd\u5229\u7528ByteBuddy\u6280\u672f\u8bbe\u7f6e\u4e86MockMethodInterceptor\u62e6\u622a\u5668\uff0cMockMethodInterceptor \u7684\u4e3b\u8981\u4f5c\u7528\u662f\u5c06 mock \u5bf9\u8c61\u7684\u62e6\u622a\u65b9\u6cd5\u6267\u884c\u4ea4\u7ed9\u4e86 MockHandler \u6765\u5904\u7406\uff0c\u4e5f\u5c31\u662f\u6700\u7ec8mock\u5b9e\u4f8b\u5bf9\u8c61\u7684\u6240\u6709\u65b9\u6cd5\u90fd\u4f1a\u8c03\u7528MockHandlerImpl\u7684handle\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u9700\u8981\u91cd\u70b9\u5173\u6ce8\uff08\u6b63\u6587\u4f1a\u8be6\u7ec6\u8bf4\u660e\uff09\u3002<\/p>\n\n\n\n<p><br>\u81f3\u4e8ewhen()\u65b9\u6cd5\u5c31\u662f\u4eceThreadLocal\u83b7\u53d6OngoingStubbingImpl\uff0c\u800cthenReturn\u5c31\u662f\u5c06\u6211\u4eec\u6307\u5b9a\u7684\u81ea\u5b9a\u4e49\u8fd4\u56de\u503c\u653e\u5165OngoingStubbingImpl\u4e2d\u7684InvocationContainerImpl\u5c5e\u6027\u4e2d\uff08InvocationContainerImpl\u5bf9\u8c61\u5f15\u7528\u5728MockHandlerImpl\u4e2d\u4e5f\u6709\uff09\uff0c\u5f53\u8c03\u7528mock\u4ee3\u7406\u7c7b\u7684\u65b9\u6cd5\u65f6\uff0c\u5c31\u4f1a\u4eceInvocationContainerImpl\u53d6\u51fa\u6307\u5b9a\u7684answer\uff08\u5c31\u662f\u4f60\u81ea\u5b9a\u4e49\u8fd4\u56de\u503c\u7684\u5305\u88c5\u5bf9\u8c61\uff09\uff0c\u5e76\u5c06\u5176\u4e2d\u7684\u503c\u8fd4\u56de\u3002<\/p>\n\n\n\n<p><br>\u90a3\u4e48verify()\u65b9\u6cd5\u7684\u6838\u5fc3\u903b\u8f91\u5c31\u662f\u8c03\u7528ArgumentMatcher\u7684matches\u65b9\u6cd5\u6765\u5224\u65admock\u5bf9\u8c61\u65b9\u6cd5\u5165\u53c2\u662f\u5426\u7b26\u5408\u6211\u4eec\u7684\u9884\u671f\u3002<\/p>\n\n\n\n<p><br>\u4ee5\u4e0a\u5c31\u662fMockito\u6e90\u7801\u7684\u4e3b\u8981\u6838\u5fc3\u903b\u8f91\u7b80\u4ecb\uff0c\u5176\u4ed6\u66f4\u7ec6\u8282\u7684\u903b\u8f91\u53ef\u4ee5\u7ee7\u7eed\u5f80\u4e0b\u770b\u6b63\u6587\u8bb2\u89e3\u3002\u8be5\u6587\u7ae0\u4e3b\u8981\u4ece\u56db\u4e2a\u90e8\u5206\u8fdb\u884c\u8bb2\u89e3\uff1amock\u4ee3\u7406\u5bf9\u8c61\u521b\u5efa\u3001mock\u5bf9\u8c61\u65b9\u6cd5\u7684\u6253\u6869\u3001mock\u5bf9\u8c61\u65b9\u6cd5\u7684\u8c03\u7528\u3001mock\u5bf9\u8c61\u65b9\u6cd5\u7684\u5165\u53c2\u9a8c\u8bc1\uff0c\u672c\u6587\u6240\u4f7f\u7528\u7684\u5355\u5143\u6d4b\u8bd5\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\u6240\u793a\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import org.junit.Test;\nimport org.mockito.Mockito;\n \nimport java.util.List;\n \n\/**\n * @description:\n * @author: zhangyuxuan\n * @date: 2021\/10\/4 \u4e0b\u53487:44 \u5468\u4e00\n *\/\npublic class MockitoCodeTest {\n    @Test\n    @SuppressWarnings(\"unchecked\")\n    public void test1() {\n        List&lt;String> mock = Mockito.mock(List.class);\n        Mockito.when(mock.get(0)).thenReturn(\"123\");\n        Mockito.doReturn(\"123\").when(mock).get(0);\n        System.out.println(mock.get(0));\n        Mockito.verify(mock).get(0);\n    }\n}<\/pre>\n\n\n\n<p><strong>\u4e8c\u3001mock\u4ee3\u7406\u5bf9\u8c61\u521b\u5efa<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p> \u4e0b\u9762\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bf4\u660e\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">List&lt;String> mock = Mockito.mock(List.class);<\/pre>\n\n\n\n<p>\u4e0a\u9762\u7684\u4f8b\u5b50\u4e00\u822c\u662f\u6211\u4eecmock\u7684\u5165\u53e3\uff0c\u8c03\u7528Mockito\u7684\u9759\u6001\u6cd5\u65b9\u6cd5 T mock(Class classToMock)\uff0cMockito\u4e2dmock\u91cd\u8f7d\u65b9\u6cd5\u6709\u597d\u51e0\u4e2a\uff0c\u4e0d\u8fc7\u6700\u7ec8\u90fd\u662f\u8c03\u7528\u7684 T mock(Class classToMock, MockSettings mockSettings)\u65b9\u6cd5\uff0c\u5177\u4f53\u8c03\u7528\u5173\u7cfb\u548c\u8fd4\u56de\u503c\u53ef\u4ee5\u53c2\u7167\u4e0b\u9762\u7684\u65f6\u5e8f\u56fe\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-1024x400.png\" alt=\"\" class=\"wp-image-9940\" width=\"523\" height=\"204\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-1024x400.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-300x117.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-768x300.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-1536x600.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-2048x800.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-830x324.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-230x90.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-350x137.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-83-480x187.png 480w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/figure><\/div>\n\n\n\n<p><br>\u521b\u5efaMock\u5bf9\u8c61\u7684\u6838\u5fc3\u65b9\u6cd5-<strong>createMock()<\/strong>\u7684\u6d41\u7a0b\u56fe\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-978x1024.png\" alt=\"\" class=\"wp-image-9941\" width=\"465\" height=\"486\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-978x1024.png 978w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-287x300.png 287w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-768x804.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-830x869.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-230x241.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-350x366.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84-480x503.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/\u56fe\u7247-84.png 1190w\" sizes=\"(max-width: 465px) 100vw, 465px\" \/><\/figure><\/div>\n\n\n\n<p>\u4e0b\u9762\u770b\u4e00\u4e0bSubclassByteBuddyMockMaker\u4e2d\u7684<strong>createMock()<\/strong>\u65b9\u6cd5\u7684\u6e90\u4ee3\u7801\uff0c\u5173\u952e\u70b9\u90fd\u52a0\u4e86\u4e00\u4e9b\u6ce8\u91ca\uff0c\u8fd9\u91cc\u5c31\u4e0d\u518d\u6587\u5b57\u8d58\u8ff0\u4e86\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public &lt;T> T createMock(MockCreationSettings&lt;T> settings, MockHandler handler) {\n        \/\/\u8fd9\u91cc\u5229\u7528ByteBuddy\u52a8\u6001\u751f\u6210mock\u7c7b\n        Class&lt;? extends T> mockedProxyType = createMockType(settings);\n \n        Instantiator instantiator = Plugins.getInstantiatorProvider().getInstantiator(settings);\n        T mockInstance = null;\n        try {\n            \/\/\u6839\u636e\u7c7b\u751f\u6210\u5bf9\u8c61\u5b9e\u4f8b\uff0c\u4f7f\u7528Objenesis\u6280\u672f\n            mockInstance = instantiator.newInstance(mockedProxyType);\n            \/\/\u751f\u6210\u7684\u52a8\u6001\u7c7b\u5b9e\u73b0\u4e86MockAccess\uff0c\u5c06MockMethodInterceptor\u5bf9\u8c61\u5b9e\u4f8b\u653e\u5165\u4ee3\u7406\u7c7b\u7684\u5c5e\u6027\u4e2d\n            MockAccess mockAccess = (MockAccess) mockInstance;\n            mockAccess.setMockitoInterceptor(new MockMethodInterceptor(handler, settings));\n \n            \/\/\u4ecesettings\u4e2d\u83b7\u53d6mockToType\u7c7b\u578b\uff0c\u7136\u540e\u5c06mockInstance\u5f3a\u8f6c\u6210mockToType\u7c7b\u578b\n            return ensureMockIsAssignableToMockedType(settings, mockInstance);\n        } catch (ClassCastException cce) {\n            throw new MockitoException(\n                    join(\n                            \"ClassCastException occurred while creating the mockito mock :\",\n                            \"  class to mock : \" + describeClass(settings.getTypeToMock()),\n                            \"  created class : \" + describeClass(mockedProxyType),\n                            \"  proxy instance class : \" + describeClass(mockInstance),\n                            \"  instance creation by : \" + instantiator.getClass().getSimpleName(),\n                            \"\",\n                            \"You might experience classloading issues, please ask the mockito mailing-list.\",\n                            \"\"),\n                    cce);\n        } catch (org.mockito.creation.instance.InstantiationException e) {\n            throw new MockitoException(\n                    \"Unable to create mock instance of type '\"\n                            + mockedProxyType.getSuperclass().getSimpleName()\n                            + \"'\",\n                    e);\n        }\n    }<\/pre>\n\n\n\n<p>\u518d\u5c55\u793a\u4e0bSubclassBytecodeGenerator\u7684mockClass()\u65b9\u6cd5\u4e2d\u7684\u5173\u952e\u4ee3\u7801\uff0c\u8fd9\u4e2a\u4ee3\u7801\u6211\u6709\u505a\u6539\u52a8\uff0c\u56e0\u4e3a\u4f7f\u7528saveIn()\u65b9\u6cd5\u5c06\u751f\u6210\u7684\u52a8\u6001\u4ee3\u7406\u7c7b\u4ece\u5185\u5b58\u4e2d\u8f93\u51fa\u5230\u6307\u5b9a\u7684\u8def\u5f84\u4e0b\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u67e5\u770b\u52a8\u6001\u751f\u6210\u7684class\u6587\u4ef6\u4e86\u3002<\/p>\n\n\n\n<p>\u5173\u4e8eByteBuddy\u6280\u672f\u7684\u4e86\u89e3\uff0c\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u6587\u6863\uff1a<\/p>\n\n\n\n<p id=\"id-gpUal6bC3J\"><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/151843984\">ByteBuddy\u5165\u95e8\u6559\u7a0b &#8211; \u77e5\u4e4e<\/a><\/p>\n\n\n\n<p id=\"id-6gBHgE93Yu\"><a href=\"https:\/\/blog.csdn.net\/wanxiaoderen\/article\/details\/106544773\">bytebuddy\u7b80\u5355\u5165\u95e8_wanxiaoderen\u7684\u535a\u5ba2-CSDN\u535a\u5ba2_bytebuddy<\/a><\/p>\n\n\n\n<p id=\"id-v7tV5ynJHn\">\u5b98\u65b9\u6587\u6863\uff1a<a href=\"https:\/\/bytebuddy.net\/#\/tutorial\">Byte Buddy &#8211; runtime code generation for the Java virtual machine<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/\u8fd9\u91cc\u5229\u7528ByteBuddy\u5b57\u8282\u7801\u589e\u5f3a\u6280\u672f\u52a8\u6001\u751f\u6210\u7c7b\n        DynamicType.Builder&lt;T> builder =\n                byteBuddy\n                        .subclass(features.mockedType)\n                        .name(name)\n                        .ignoreAlso(isGroovyMethod())\n                        .annotateType(\n                                features.stripAnnotations\n                                        ? new Annotation[0]\n                                        : features.mockedType.getAnnotations())\n                        .implement(new ArrayList&lt;Type>(features.interfaces))\n                        .method(matcher)\n                        .intercept(dispatcher)\n                        .transform(withModifiers(SynchronizationState.PLAIN))\n                        .attribute(\n                                features.stripAnnotations\n                                        ? MethodAttributeAppender.NoOp.INSTANCE\n                                        : INCLUDING_RECEIVER)\n                        .serialVersionUid(42L)\n                        .defineField(\"mockitoInterceptor\", MockMethodInterceptor.class, PRIVATE)\n                        .implement(MockAccess.class)\n                        .intercept(FieldAccessor.ofBeanProperty())\n                        .method(isHashCode())\n                        .intercept(hashCode)\n                        .method(isEquals())\n                        .intercept(equals);\n \n        DynamicType.Unloaded&lt;T> unloaded = builder.make();\n        try {\n            \/\/\u8fd9\u91cc\u4f7f\u7528saveIn\u65b9\u6cd5\u5c06\u52a8\u6001\u751f\u6210\u7684\u7c7b\u8f93\u51fa\u5230\u6307\u5b9a\u76ee\u5f55\u4e0b\n            unloaded.saveIn(new File(\"\/Users\/zhangyuxuan\/IdeaProjects\/coding\/mockito\/src\/test\/java\/org\"));\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n        return unloaded\n                .load(\n                        classLoader,\n                        loader.resolveStrategy(features.mockedType, classLoader, localMock))\n                .getLoaded();<\/pre>\n\n\n\n<p>\u4e0b\u9762\u5c55\u793a\u4e0bByteBuddy\u6280\u672f\u751f\u6210\u7684\u52a8\u6001\u4ee3\u7406\u7c7b\uff0c\u4ee5\u65b9\u4fbf\u5927\u5bb6\u7406\u89e3\u3002\u4e3a\u4e86\u4fdd\u8bc1\u5b8c\u6574\u6027\uff0c\u5c31\u4e0d\u5bf9\u4e0b\u9762\u4ee3\u7801\u7cbe\u7b80\u4e86\uff0c\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u5bf9\u6bd4\u67e5\u770b\u4e00\u4e0b\uff0c\u5b9e\u9645\u4e0a\u53ea\u9700\u8981\u5c55\u793aget\u65b9\u6cd5\u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">package org.mockito.codegen;\n \nimport java.util.Collection;\nimport java.util.Comparator;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.ListIterator;\nimport java.util.Spliterator;\nimport java.util.function.Consumer;\nimport java.util.function.Predicate;\nimport java.util.function.UnaryOperator;\nimport java.util.stream.Stream;\nimport org.mockito.internal.creation.bytebuddy.MockAccess;\nimport org.mockito.internal.creation.bytebuddy.MockMethodInterceptor;\nimport org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.DispatcherDefaultingToRealMethod;\nimport org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.ForEquals;\nimport org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.ForHashCode;\n \npublic class List$MockitoMock$890335103 implements List, MockAccess {\n    private static final long serialVersionUID = 42L;\n    private MockMethodInterceptor mockitoInterceptor;\n \n    public String toString() {\n        return (String)DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$4cscpe1, new Object[0], new List$MockitoMock$890335103$auxiliary$FtDVeNQv(this));\n    }\n \n    protected Object clone() throws CloneNotSupportedException {\n        return DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$7m9oaq0, new Object[0], new List$MockitoMock$890335103$auxiliary$s7kgjZIM(this));\n    }\n \n    public void forEach(Consumer var1) {\n        DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$ascqpd0, new Object[]{var1}, new List$MockitoMock$890335103$auxiliary$3a9hfkuz(this, var1));\n    }\n \n    public Stream stream() {\n        return (Stream)DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$4i8d8f1, new Object[0], new List$MockitoMock$890335103$auxiliary$n8Rih3Nh(this));\n    }\n \n    public boolean removeIf(Predicate var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$aqin4c0, new Object[]{var1}, new List$MockitoMock$890335103$auxiliary$RoVqxHRT(this, var1));\n    }\n \n    public Stream parallelStream() {\n        return (Stream)DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$bbf8080, new Object[0], new List$MockitoMock$890335103$auxiliary$dqMXE3c5(this));\n    }\n \n    public boolean add(Object var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$sgg2351, new Object[]{var1});\n    }\n \n    public void add(int var1, Object var2) {\n        DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$3us6oc3, new Object[]{var1, var2});\n    }\n \n    public boolean remove(Object var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$v9lk1j0, new Object[]{var1});\n    }\n \n    public Object remove(int var1) {\n        return DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$gs4cee0, new Object[]{var1});\n    }\n \n    public Object get(int var1) {\n        return DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$2ff4l01, new Object[]{var1});\n    }\n \n    public boolean equals(Object var1) {\n        return ForEquals.doIdentityEquals(this, var1);\n    }\n \n    public int hashCode() {\n        return ForHashCode.doIdentityHashCode(this);\n    }\n \n    public int indexOf(Object var1) {\n        return (Integer)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, 0, cachedValue$MFvvCWXe$tm4die2, new Object[]{var1});\n    }\n \n    public void clear() {\n        DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$bp48n33, new Object[0]);\n    }\n \n    public boolean isEmpty() {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$dc8ju02, new Object[0]);\n    }\n \n    public int lastIndexOf(Object var1) {\n        return (Integer)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, 0, cachedValue$MFvvCWXe$77a53p0, new Object[]{var1});\n    }\n \n    public boolean contains(Object var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$q0m7l61, new Object[]{var1});\n    }\n \n    public void replaceAll(UnaryOperator var1) {\n        DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$61en0h1, new Object[]{var1}, new List$MockitoMock$890335103$auxiliary$j6mAFEJB(this, var1));\n    }\n \n    public int size() {\n        return (Integer)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, 0, cachedValue$MFvvCWXe$479u1c1, new Object[0]);\n    }\n \n    public List subList(int var1, int var2) {\n        return (List)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$idijvh3, new Object[]{var1, var2});\n    }\n \n    public Object[] toArray() {\n        return (Object[])DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$pa58dn1, new Object[0]);\n    }\n \n    public Object[] toArray(Object[] var1) {\n        return (Object[])DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$eqbjn92, new Object[]{var1});\n    }\n \n    public Iterator iterator() {\n        return (Iterator)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$itsld03, new Object[0]);\n    }\n \n    public Spliterator spliterator() {\n        return (Spliterator)DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$ialm821, new Object[0], new List$MockitoMock$890335103$auxiliary$5pfANSxk(this));\n    }\n \n    public boolean addAll(Collection var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$6epee82, new Object[]{var1});\n    }\n \n    public boolean addAll(int var1, Collection var2) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$pqjhh82, new Object[]{var1, var2});\n    }\n \n    public Object set(int var1, Object var2) {\n        return DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$5p89p02, new Object[]{var1, var2});\n    }\n \n    public boolean containsAll(Collection var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$8o98bj1, new Object[]{var1});\n    }\n \n    public boolean removeAll(Collection var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$3um2h43, new Object[]{var1});\n    }\n \n    public boolean retainAll(Collection var1) {\n        return (Boolean)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, false, cachedValue$MFvvCWXe$2v2l442, new Object[]{var1});\n    }\n \n    public ListIterator listIterator(int var1) {\n        return (ListIterator)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$vv27a83, new Object[]{var1});\n    }\n \n    public ListIterator listIterator() {\n        return (ListIterator)DispatcherDefaultingToRealMethod.interceptAbstract(this, this.mockitoInterceptor, (Object)null, cachedValue$MFvvCWXe$ivs3a83, new Object[0]);\n    }\n \n    public void sort(Comparator var1) {\n        DispatcherDefaultingToRealMethod.interceptSuperCallable(this, this.mockitoInterceptor, cachedValue$MFvvCWXe$g7qoll1, new Object[]{var1}, new List$MockitoMock$890335103$auxiliary$xGvgLT35(this, var1));\n    }\n \n    public void setMockitoInterceptor(MockMethodInterceptor var1) {\n        this.mockitoInterceptor = var1;\n    }\n \n    public MockMethodInterceptor getMockitoInterceptor() {\n        return this.mockitoInterceptor;\n    }\n \n    public List$MockitoMock$890335103() {\n    }\n \n    static {\n        cachedValue$MFvvCWXe$gs4cee0 = List.class.getMethod(\"remove\", Integer.TYPE);\n        cachedValue$MFvvCWXe$77a53p0 = List.class.getMethod(\"lastIndexOf\", Object.class);\n        cachedValue$MFvvCWXe$479u1c1 = List.class.getMethod(\"size\");\n        cachedValue$MFvvCWXe$pa58dn1 = List.class.getMethod(\"toArray\");\n        cachedValue$MFvvCWXe$2v2l442 = List.class.getMethod(\"retainAll\", Collection.class);\n        cachedValue$MFvvCWXe$itsld03 = List.class.getMethod(\"iterator\");\n        cachedValue$MFvvCWXe$tm4die2 = List.class.getMethod(\"indexOf\", Object.class);\n        cachedValue$MFvvCWXe$idijvh3 = List.class.getMethod(\"subList\", Integer.TYPE, Integer.TYPE);\n        cachedValue$MFvvCWXe$ialm821 = List.class.getMethod(\"spliterator\");\n        cachedValue$MFvvCWXe$vv27a83 = List.class.getMethod(\"listIterator\", Integer.TYPE);\n        cachedValue$MFvvCWXe$4cscpe1 = Object.class.getMethod(\"toString\");\n        cachedValue$MFvvCWXe$pqjhh82 = List.class.getMethod(\"addAll\", Integer.TYPE, Collection.class);\n        cachedValue$MFvvCWXe$bp48n33 = List.class.getMethod(\"clear\");\n        cachedValue$MFvvCWXe$8o98bj1 = List.class.getMethod(\"containsAll\", Collection.class);\n        cachedValue$MFvvCWXe$3um2h43 = List.class.getMethod(\"removeAll\", Collection.class);\n        cachedValue$MFvvCWXe$ascqpd0 = Iterable.class.getMethod(\"forEach\", Consumer.class);\n        cachedValue$MFvvCWXe$5p89p02 = List.class.getMethod(\"set\", Integer.TYPE, Object.class);\n        cachedValue$MFvvCWXe$g7qoll1 = List.class.getMethod(\"sort\", Comparator.class);\n        cachedValue$MFvvCWXe$6epee82 = List.class.getMethod(\"addAll\", Collection.class);\n        cachedValue$MFvvCWXe$ivs3a83 = List.class.getMethod(\"listIterator\");\n        cachedValue$MFvvCWXe$bbf8080 = Collection.class.getMethod(\"parallelStream\");\n        cachedValue$MFvvCWXe$3us6oc3 = List.class.getMethod(\"add\", Integer.TYPE, Object.class);\n        cachedValue$MFvvCWXe$61en0h1 = List.class.getMethod(\"replaceAll\", UnaryOperator.class);\n        cachedValue$MFvvCWXe$7m9oaq0 = Object.class.getDeclaredMethod(\"clone\");\n        cachedValue$MFvvCWXe$4i8d8f1 = Collection.class.getMethod(\"stream\");\n        cachedValue$MFvvCWXe$v9lk1j0 = List.class.getMethod(\"remove\", Object.class);\n        cachedValue$MFvvCWXe$q0m7l61 = List.class.getMethod(\"contains\", Object.class);\n        cachedValue$MFvvCWXe$eqbjn92 = List.class.getMethod(\"toArray\", Object[].class);\n        cachedValue$MFvvCWXe$2ff4l01 = List.class.getMethod(\"get\", Integer.TYPE);\n        cachedValue$MFvvCWXe$aqin4c0 = Collection.class.getMethod(\"removeIf\", Predicate.class);\n        cachedValue$MFvvCWXe$sgg2351 = List.class.getMethod(\"add\", Object.class);\n        cachedValue$MFvvCWXe$dc8ju02 = List.class.getMethod(\"isEmpty\");\n    }\n}<\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662fmockito\u6846\u67b6\u52a8\u6001\u751f\u6210mock\u4ee3\u7406\u7c7b\u751f\u6210\u7684\u8fc7\u7a0b\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u7ee7\u7eed\u540e\u9762\u7684\u5206\u4eab\u3002<\/p>\n\n\n\n<p><strong>\u4e09\u3001mock\u5bf9\u8c61\u65b9\u6cd5\u7684\u6253\u6869<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5e38\u7528\u7684\u6253\u6869\u65b9\u5f0f\u6709\u4e24\u79cd\uff0c\u4e0b\u9762\u5c31\u5206\u522b\u8fdb\u884c\u6e90\u7801\u5206\u6790\uff1b<\/p>\n\n\n\n<p>\u7b2c\u4e00\u79cd\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Mockito.when(mock.get(0)).thenReturn(\"123\");<\/pre>\n\n\n\n<p>\u5148\u8bf4when\u65b9\u6cd5\u4e2d\u7684mock.get(0)\uff0c\u8fd9\u91cc\u8c03\u7528\u4e86mock\u4ee3\u7406\u7c7b\u7684get\u65b9\u6cd5\uff0c\u4f1a\u8c03\u7528MockHandlerImpl\u4e2d\u7684handle\u65b9\u6cd5\uff0c\u521b\u5efaOngoingStubbingImpl\u5e76\u653e\u5165ThreadLocal\u4e2d\uff08\u5b9e\u9645\u4e0a\u662f\u653e\u5165MockingProgressImpl\u4e2d\uff0c\u7136\u540eMockingProgressImpl\u518d\u653e\u5165ThreadLocal\u4e2d\uff0c\u6211\u4eec\u8fd8\u662f\u6311\u91cd\u70b9\u8bf4\uff0c\u65e0\u5173\u7d27\u8981\u7684\u7ec6\u8282\u7701\u7565\u6389\uff0c\u611f\u5174\u8da3\u7684\u53ef\u4ee5\u81ea\u5df1\u4e0b\u8f7dMockito\u6e90\u7801\u67e5\u770b\uff09\uff0c\u800c\u8c03\u7528when\u65b9\u6cd5\u65f6\u5019\u4f1a\u53d6\u51fa\u521a\u624d\u653e\u5165\u7684OngoingStubbingImpl\u5bf9\u8c61\u5b9e\u4f8b\u5e76\u8fd4\u56de\uff0c\u6ce8\u610f\u8fd9\u91cc\u662fpull\u65b9\u5f0f\u53d6\u51fa\u7684\uff0c\u4e5f\u5c31\u610f\u5473\u7740\u51fa\u6765\u4ee5\u540eThreadLocal\u4e2d\u5c31\u4e0d\u5305\u542bOngoingStubbingImpl\u4e86\uff0c\u6e90\u7801\u89c1\u4e0b\u9762\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public &lt;T> OngoingStubbing&lt;T> when(T methodCall) {\/\/when\u65b9\u6cd5\u8fd4\u56deOngoingStubbingImpl\u5bf9\u8c61\u5b9e\u4f8b\n        MockingProgress mockingProgress = mockingProgress();\/\/\u83b7\u53d6MockingProgressImpl\u5bf9\u8c61\u5b9e\u4f8b\n        mockingProgress.stubbingStarted();\/\/\u7ed9MockingProgressImpl\u5b9e\u4f8b\u7684\u5c5e\u6027stubbingInProgress\u8d4b\u503cLocationImpl\u5b9e\u4f8b\n        @SuppressWarnings(\"unchecked\")\n        OngoingStubbing&lt;T> stubbing = (OngoingStubbing&lt;T>) mockingProgress.pullOngoingStubbing();\/\/\u4eceMockingProgressImpl\u5b9e\u4f8b\u4e2dpull\u51faOngoingStubbingImpl\u5b9e\u4f8b\uff0cMockingProgressImpl\u5b9e\u4f8b\u7684ongoingStubbing\u5c5e\u6027\u4f1a\u88ab\u7f6e\u7a7a\n        if (stubbing == null) {\n            mockingProgress.reset();\n            throw missingMethodInvocation();\n        }\n        return stubbing;\n    }<\/pre>\n\n\n\n<p><br><\/p>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662fwhen\u65b9\u6cd5\u7684\u4e3b\u8981\u903b\u8f91\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u8fd4\u56de\u7684OngoingStubbingImpl\u4e2d\u7684thenReturn\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u4f1a\u5c06\u4f20\u5165\u7684\u53c2\u6570\u5305\u88c5\u6210Answer\u7c7b\u578b\uff08\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u8fd4\u56de\u503c\u5c01\u88c5\u5230Answer\u5bf9\u8c61\u7684value\u5c5e\u6027\u4e2d\uff09\uff0c\u7136\u540e\u653e\u5165OngoingStubbingImpl\u4e2d\u7684InvocationContainerImpl\u5c5e\u6027\u4e2d\uff0c\u4e0d\u8fc7\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662fMockHandlerImpl\u4e2d\u4e5f\u5b58\u4e86InvocationContainerImpl\u5c5e\u6027\uff0c\u548cOngoingStubbingImpl\u4e2d\u7684\u662f\u540c\u4e00\u4e2a\uff0cthenReturn\u6e90\u7801\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    public OngoingStubbing&lt;T> thenAnswer(Answer&lt;?> answer) {\n        if (!invocationContainer.hasInvocationForPotentialStubbing()) {\n            throw incorrectUseOfApi();\n        }\n \n        invocationContainer.addAnswer(answer, strictness);\/\/\u5411InvocationContainerImpl\u4e2d\u6dfb\u52a0answer\n        return new ConsecutiveStubbing&lt;T>(invocationContainer);\/\/\u8fde\u7eed\u5b58\u6839\n    }<\/pre>\n\n\n\n<p>\u7b2c\u4e8c\u79cd\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Mockito.doReturn(\"123\").when(mock).get(0);<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u7684doReturn\u5b9e\u9645\u662f\u8c03\u7528StubberImpl\u4e2d\u7684doReturnValues\u65b9\u6cd5\uff0c\u5c06\u81ea\u5b9a\u4e49\u6307\u5b9a\u7684\u8fd4\u56de\u503c\u5c01\u88c5\u6210Answer\u653e\u5165StubberImpl\u7684\u5c5e\u6027\u4e2d\u4fdd\u5b58\u5e76\u8fd4\u56deStubberImpl\u5bf9\u8c61\u5b9e\u4f8b\uff0cStubberImpl\u4e2d\u7684when\u65b9\u6cd5\u5f53\u7136\u5c31\u4f1a\u5c06\u4fdd\u5b58\u7684Answer\u653e\u5165InvocationContainerImpl\u4e2d\u5e76\u8fd4\u56demock\u5bf9\u8c61\u5b9e\u4f8b\uff0c\u6700\u540e\u53c8\u56de\u5230MockHandlerImpl\u7684handle\u65b9\u6cd5\u4e86\uff0c\u8fd9\u91cc\u4f1a\u5c06\u6211\u4eec\u6307\u5b9aAnswer\u548cInterceptedInvocation\u7ed1\u5b9a\uff0c\u5230\u6b64\u5c31\u5b8c\u6210\u4e86\u6253\u6869\u5de5\u4f5c\uff0c\u7ed1\u5b9a\u903b\u8f91\u4ee3\u7801\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    if (invocationContainer.hasAnswersForStubbing()) {\n            \/\/ stubbing voids with doThrow() or doAnswer() style\n            InvocationMatcher invocationMatcher =\n                    matchersBinder.bindMatchers(\n                            mockingProgress().getArgumentMatcherStorage(), invocation);\n            invocationContainer.setMethodForStubbing(invocationMatcher);\n            return null;\n        }<\/pre>\n\n\n\n<p><br><strong>\u56db\u3001mock\u5bf9\u8c61\u65b9\u6cd5\u7684\u8c03\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u524d\u9762mock\u5bf9\u8c61\u548c\u6253\u6869\u90fd\u5df2\u7ecf\u51c6\u5907\u5b8c\u6210\uff0c\u63a5\u4e0b\u6765\u5c31\u8981\u8fdb\u884cmock\u5bf9\u8c61\u65b9\u6cd5\u8c03\u7528\u4e86\uff0c\u8fd8\u662f\u4ee5\u7b80\u5355\u793a\u4f8b\u4ee3\u7801\u6765\u8fdb\u884c\u8bb2\u89e3\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">System.out.println(mock.get(0));<\/pre>\n\n\n\n<p>\u524d\u9762\u6211\u4eec\u5df2\u7ecf\u8bf4\u8fc7\uff0cmock\u5bf9\u8c61\u7684\u65b9\u6cd5\u90fd\u4f1a\u8c03\u5165\u5230MockHandlerImpl\u4e2d\u7684handle\u65b9\u6cd5\uff0c\u8fd4\u56de\u7ed3\u679c\u4f1a\u4eceMockHandlerImpl\u7684InvocationContainerImpl\u5c5e\u6027\u4e2d\u53d6\u51fa\uff0c\u5177\u4f53\u4ee3\u7801\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    public Object handle(Invocation invocation) throws Throwable {\n        if (invocationContainer.hasAnswersForStubbing()) {\n            \/\/ stubbing voids with doThrow() or doAnswer() style\n            InvocationMatcher invocationMatcher =\n                    matchersBinder.bindMatchers(\n                            mockingProgress().getArgumentMatcherStorage(), invocation);\n            invocationContainer.setMethodForStubbing(invocationMatcher);\n            return null;\n        }\n        VerificationMode verificationMode = mockingProgress().pullVerificationMode();\n \n        \/\/InvocationMatcher\u5c5e\u6027\u6709Invocation\u548cList&lt;ArgumentMatcher&lt;?>>\uff0c\u901a\u5e38\u60c5\u51b5\u4e0b\u4f1a\u5c06InterceptedInvocation\u4e2d\u7684arguments\u53c2\u6570\u8f6c\u6210ArgumentMatcher\uff0c\u800cInterceptedInvocation\u5c5e\u6027\u6765\u81ea\u4e8e\u4ee3\u7406\u7c7b\u4e2d\u4f20\u5165\n        InvocationMatcher invocationMatcher =\n                matchersBinder.bindMatchers(\n                        mockingProgress().getArgumentMatcherStorage(), invocation);\n \n        mockingProgress().validateState();\n \n        \/\/ if verificationMode is not null then someone is doing verify()\n        if (verificationMode != null) {\n            \/\/ We need to check if verification was started on the correct mock\n            \/\/ - see VerifyingWithAnExtraCallToADifferentMockTest (bug 138)\n            if (MockUtil.areSameMocks(\n                    ((MockAwareVerificationMode) verificationMode).getMock(),\n                    invocation.getMock())) {\n                VerificationDataImpl data =\n                        new VerificationDataImpl(invocationContainer, invocationMatcher);\n                verificationMode.verify(data);\n                return null;\n            } else {\n                \/\/ this means there is an invocation on a different mock. Re-adding verification\n                \/\/ mode\n                \/\/ - see VerifyingWithAnExtraCallToADifferentMockTest (bug 138)\n                mockingProgress().verificationStarted(verificationMode);\n            }\n        }\n \n        \/\/ prepare invocation for stubbing\n        invocationContainer.setInvocationForPotentialStubbing(invocationMatcher);\/\/\u5c06InvocationMatcher\u5bf9\u8c61\u5b9e\u4f8b\u653e\u5165InvocationContainerImpl\u5bf9\u8c61\u5b9e\u4f8b\u7684\u5c5e\u6027MatchableInvocation\u4e2d\n        OngoingStubbingImpl&lt;T> ongoingStubbing = new OngoingStubbingImpl&lt;T>(invocationContainer);\/\/\u5c06InvocationContainerImpl\u5bf9\u8c61\u5b9e\u4f8b\u653e\u5165OngoingStubbingImpl\u5bf9\u8c61\u5b9e\u4f8b\u7684\u5c5e\u6027InvocationContainerImpl\u4e2d\n        mockingProgress().reportOngoingStubbing(ongoingStubbing);\/\/\u5c06OngoingStubbingImpl\u5bf9\u8c61\u5b9e\u4f8b\u653e\u5165MockingProgressImpl\u5bf9\u8c61\u5b9e\u4f8b\u7684\u5c5e\u6027OngoingStubbing\u4e2d\uff0c\u540e\u9762\u518dwhen\u8c03\u7528\u4e2d\u4f1a\u53d6\u51fa\u6765\u4f7f\u7528\n \n        \/\/ look for existing answer for this invocation\n        \/\/ \u8fd9\u91cc\u4f1a\u4eceInvocationContainerImpl\u5bfb\u627e\u5df2\u7ecf\u5b58\u5728\u7684\u5b58\u6839\uff0c\u7b2c\u4e00\u6b21\u4f7f\u7528when(object.method)\u7684\u65f6\u5019\uff0c\u5b58\u6839\u662f\u7a7a\uff0c\u7b2c\u4e8c\u6b21\u8c03\u7528\u5c31\u4f1a\u6709\u5b58\u6839\u4e86\u3002\n        \/\/ \u6216\u8005\u8fd9\u6837\u8bf4\u66f4\u51c6\u786e\uff0c\u5c31\u662f\u8c03\u7528OngoingStubbingImpl\u4e2d\u7684thenAnswer\u65b9\u6cd5\u540e\uff0c\u5c31\u4f1a\u5c06\u8bbe\u7f6e\u7684answer\u6700\u7ec8\u653e\u5165InvocationContainerImpl\u4e2d\u7684StubbedInvocationMatcher\u5c5e\u6027\u4e2d\u3002\n        \/\/ \u800cStubbedInvocationMatcher\u4e2d\u7684InterceptedInvocation\u4e5f\u5f88\u91cd\u8981\uff0c\u56e0\u4e3a\u65b9\u6cd5\u7684\u6bd4\u8f83\u548c\u5339\u914d\u9700\u8981\u7528\u5230\uff0c\u8fd9\u4e2a\u5c5e\u6027\u503c\u662f\u5728\u3002\n        StubbedInvocationMatcher stubbing = invocationContainer.findAnswerFor(invocation);\n        \/\/ TODO #793 - when completed, we should be able to get rid of the casting below\n        notifyStubbedAnswerLookup(\n                invocation,\n                stubbing,\n                invocationContainer.getStubbingsAscending(),\n                (CreationSettings) mockSettings);\n \n        if (stubbing != null) {\n            stubbing.captureArgumentsFrom(invocation);\n \n            try {\n                return stubbing.answer(invocation);\n            } finally {\n                \/\/ Needed so that we correctly isolate stubbings in some scenarios\n                \/\/ see MockitoStubbedCallInAnswerTest or issue #1279\n                mockingProgress().reportOngoingStubbing(ongoingStubbing);\/\/\u5728\u8fd4\u56de\u6253\u6869\u6307\u5b9a\u7684\u8fd4\u56de\u503c\u4ee5\u540e\uff0c\u518d\u628aOngoingStubbingImpl\u653e\u5165MockingProgressImpl\u4e2d\n            }\n        } else {\/\/\u7b2c\u4e00\u6b21\u8c03\u7528\u4f1a\u8d70\u8fd9\u4e2a\u5206\u652f\uff0c\u6216\u8005\u8bf4\u6ca1\u6709\u8fdb\u884c\u6253\u6869\u4e4b\u524d\uff0c\u90fd\u662f\u8d70\u7740\u5206\u652f\n            Object ret = mockSettings.getDefaultAnswer().answer(invocation);\n            DefaultAnswerValidator.validateReturnValueFor(invocation, ret);\n \n            \/\/ Mockito uses it to redo setting invocation for potential stubbing in case of partial\n            \/\/ mocks \/ spies.\n            \/\/ Without it, the real method inside 'when' might have delegated to other self method\n            \/\/ and overwrite the intended stubbed method with a different one.\n            \/\/ This means we would be stubbing a wrong method.\n            \/\/ Typically this would led to runtime exception that validates return type with stubbed\n            \/\/ method signature.\n            invocationContainer.resetInvocationForPotentialStubbing(invocationMatcher);\n            return ret;\n        }\n    }<\/pre>\n\n\n\n<p>\u5982\u4e0a\u6240\u8bf4\uff0c\u6211\u4eec\u5c31\u5b9e\u73b0\u4e86mock\u4ee3\u7406\u7c7b\u7684\u65b9\u6cd5\u8fd4\u56de\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u8fd4\u56de\u503c\uff0c\u81f3\u6b64\u6838\u5fc3\u4ee3\u7801\u7684\u6838\u5fc3\u903b\u8f91\u5df2\u7ecf\u5f88\u6e05\u6670\u4e86\u3002<\/p>\n\n\n\n<p><strong>\u4e94\u3001mock\u5bf9\u8c61\u65b9\u6cd5\u7684\u5165\u53c2\u9a8c\u8bc1<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6211\u4eec\u9664\u4e86\u5bf9\u5355\u5143\u6d4b\u8bd5\u7684\u8fd4\u56de\u7ed3\u679c\u8fdb\u884c\u9a8c\u8bc1\uff0c\u8fd8\u9700\u8981\u5bf9mock\u5bf9\u8c61\u7684\u65b9\u6cd5\u8c03\u7528\u7684\u5165\u53c2\u8fdb\u884c\u9a8c\u8bc1\uff0c\u770b\u770b\u5165\u53c2\u662f\u4e0d\u662f\u548c\u6211\u4eec\u9884\u671f\u662f\u4e00\u81f4\u7684\uff0c\u8fd9\u5c31\u8981\u4f7f\u7528verify\u65b9\u6cd5\u8fdb\u884c\u9a8c\u8bc1\u4e86\uff0c\u4e0b\u9762\u8fd8\u662f\u7528\u6700\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bb2\u89e3\u6e90\u7801\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Mockito.verify(mock).get(0);<\/pre>\n\n\n\n<p>verify\u65b9\u6cd5\u50cfmock\u548cwhen\u65b9\u6cd5\u4e00\u6837\uff0c\u8c03\u7528\u7684\u4e5f\u662fMockitoCore\u4e2d\u7684\u540c\u540d\u65b9\u6cd5\uff0c\u5165\u53c2\u4e2dVerificationMode\u7c7b\u578b\u53c2\u6570\u5982\u679c\u4e0d\u4f20\uff0c\u9ed8\u8ba4\u5c31\u4f1a\u662ftimes(1)\u65b9\u6cd5\u8fd4\u56de\u7684Times\u5bf9\u8c61\u5b9e\u4f8b\uff0c\u8c03\u7528\u8fc7\u7a0b\u4e2d\u4f1a\u5c06VerificationMode\u653e\u5165ThreadLocal\u4e2d\uff0c\u5176\u8fd4\u56de\u503c\u901a\u5e38\u5c31\u662f\u4f20\u5165\u7684mock\u5bf9\u8c61\uff0c\u5177\u4f53\u7ec6\u8282\u89c1\u4e0b\u9762\u6838\u5fc3\u6e90\u7801\u3002<br><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    public &lt;T> T verify(T mock, VerificationMode mode) {\n        if (mock == null) {\n            throw nullPassedToVerify();\n        }\n        MockingDetails mockingDetails = mockingDetails(mock);\n        if (!mockingDetails.isMock()) {\n            throw notAMockPassedToVerify(mock.getClass());\n        }\n        assertNotStubOnlyMock(mock);\n        MockHandler handler = mockingDetails.getMockHandler();\n        mock =\n                (T)\n                        VerificationStartedNotifier.notifyVerificationStarted(\/\/\u901a\u5e38\u60c5\u51b5\u4e0b\u8fd9\u8fd4\u56de\u7684mock\u5bf9\u8c61\u8fd8\u662fDefaultMockingDetails\u4e2d\u7684mock\u5bf9\u8c61\uff0c\u4e5f\u5c31\u662f\u4f20\u5165\u7684mock\u5bf9\u8c61\n                                handler.getMockSettings().getVerificationStartedListeners(),\n                                mockingDetails);\n \n        MockingProgress mockingProgress = mockingProgress();\n        VerificationMode actualMode = mockingProgress.maybeVerifyLazily(mode);\n        mockingProgress.verificationStarted(\/\/\u5c06VerificationMode\u8bbe\u7f6e\u5230MockingProgressImpl\u4e2d\u7684Localized&lt;VerificationMode>\u5c5e\u6027\n                new MockAwareVerificationMode(\n                        mock, actualMode, mockingProgress.verificationListeners()));\n        return mock;\n    }<\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u53c8\u8981\u56de\u5230MockHandlerImpl\u7684handle\u65b9\u6cd5\u8c03\u7528\u4e2d\u4e86\uff0c\u4e0a\u9762\u5df2\u7ecf\u5c55\u793a\u8fc7\u6e90\u4ee3\u7801\uff0c\u8fd9\u91cc\u5c31\u6839\u636e\u8bb2\u89e3\uff0c\u622a\u53d6\u7247\u6bb5\u8fdb\u884c\u8bf4\u660e\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">invocationContainer.setInvocationForPotentialStubbing(invocationMatcher);\/\/\u5c06InvocationMatcher\u5bf9\u8c61\u5b9e\u4f8b\u653e\u5165InvocationContainerImpl\u5bf9\u8c61\u5b9e\u4f8b\u7684\u5c5e\u6027MatchableInvocation\u4e2d\uff1b\u5c06\u6bcf\u6b21\u8c03\u7528\u7684InterceptedInvocation\u653e\u5230DefaultRegisteredInvocations\u7684LinkedList&lt;Invocation>\u5c5e\u6027\u4e2d\uff0c\u4ee5\u505a\u8bb0\u5f55\n<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u4f1a\u8bb0\u5f55\u6bcf\u6b21mock\u4ee3\u7406\u5bf9\u8c61\u7684\u65b9\u6cd5\u8c03\u7528\u7684InterceptedInvocation\uff0c\u653e\u5165List\u4e2d\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    VerificationMode verificationMode = mockingProgress().pullVerificationMode();\/\/\u8fd9\u91ccpull\u51faVerificationMode\uff0c\u5728verify\u7684\u65f6\u5019\u4f1a\u7528\u5230\n \n        \/\/InvocationMatcher\u5c5e\u6027\u6709Invocation\u548cList&lt;ArgumentMatcher&lt;?>>\uff0c\u901a\u5e38\u60c5\u51b5\u4e0b\u4f1a\u5c06InterceptedInvocation\u4e2d\u7684arguments\u53c2\u6570\u8f6c\u6210ArgumentMatcher\uff0c\u800cInterceptedInvocation\u5c5e\u6027\u6765\u81ea\u4e8e\u4ee3\u7406\u7c7b\u4e2d\u4f20\u5165\n        InvocationMatcher invocationMatcher =\n                matchersBinder.bindMatchers(\n                        mockingProgress().getArgumentMatcherStorage(), invocation);\n \n        mockingProgress().validateState();\n \n        \/\/ if verificationMode is not null then someone is doing verify()\n        if (verificationMode != null) {\n            \/\/ We need to check if verification was started on the correct mock\n            \/\/ - see VerifyingWithAnExtraCallToADifferentMockTest (bug 138)\n            if (MockUtil.areSameMocks(\n                    ((MockAwareVerificationMode) verificationMode).getMock(),\n                    invocation.getMock())) {\n                VerificationDataImpl data =\/\/\u83b7\u53d6\u9a8c\u8bc1\u6570\u636e\n                        new VerificationDataImpl(invocationContainer, invocationMatcher);\n                verificationMode.verify(data);\n                return null;\n            } else {\n                \/\/ this means there is an invocation on a different mock. Re-adding verification\n                \/\/ mode\n                \/\/ - see VerifyingWithAnExtraCallToADifferentMockTest (bug 138)\n                mockingProgress().verificationStarted(verificationMode);\n            }\n        }<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u4f1a\u53d6\u51fa\u5728verify\u8c03\u7528\u65f6\u5019\u653e\u5165\u7684VerificationMode\uff0c\u7136\u540e\u8c03\u7528\u5176verify\u65b9\u6cd5\uff0c\u76f8\u5173\u6570\u636e\u4f1a\u901a\u8fc7VerificationDataImpl\u4f20\u5165\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    public void verify(VerificationData data) {\n        List&lt;Invocation> invocations = data.getAllInvocations();\n        MatchableInvocation wanted = data.getTarget();\n \n        if (wantedCount > 0) {\n            checkMissingInvocation(data.getAllInvocations(), data.getTarget());\n        }\n        checkNumberOfInvocations(invocations, wanted, wantedCount);\n    }<\/pre>\n\n\n\n<p>checkMissingInvocation\u65b9\u6cd5\u4e2d\u4f1a\u5c06\u521a\u624d\u5728handle\u65b9\u6cd5\u4e2d\u8bb0\u5f55\u7684InterceptedInvocation\u7c7b\u578b\u7684list\u4e2d\u7684\u76f8\u540c\u65b9\u6cd5\uff08\u4f1a\u5bf9\u6bd4\u65b9\u6cd5\u540d\u548c\u5165\u53c2\u7c7b\u578b\uff09\u548c\u5f53\u524dVerificationMode\u4e2d\u7684\u8fdb\u884c\u5339\u914d\uff08\u5bf9\u4e8e\u672c\u6587\u7684\u4f8b\u5b50\u6765\u8bf4\u5c31\u662f\u5bf9\u6bd4\u65b9\u6cd5\u540d\u548c\u5165\u53c2\u7c7b\u578b\u4ee5\u53ca\u5165\u53c2\u503c\u662f\u5426\u4e00\u81f4\uff09\uff0c\u5982\u679c\u6ca1\u6709\u53d1\u73b0\u5339\u914d\u7684\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\u3002<\/p>\n\n\n\n<p>checkNumberOfInvocations\u65b9\u6cd5\u4f1a\u5c06InterceptedInvocation\u7c7b\u578b\u7684list\u548cTimes\u4e2d\u7684wantedCount\u8fdb\u884c\u5bf9\u6bd4\uff0c\u4e0d\u4e00\u81f4\u5c06\u629b\u51fa\u5f02\u5e38\uff1b<\/p>\n\n\n\n<p>\u81f3\u6b64\uff0c\u4e00\u4e2a\u6700\u7b80\u5355\u7684Mockito\u5355\u5143\u6d4b\u8bd5\u793a\u4f8b\u7684\u6e90\u4ee3\u7801\u5c31\u5206\u6790\u5b8c\u4e86\uff0c\u63a5\u4e0b\u6765\u518d\u5bf9\u5e38\u7528\u7684verify\u5199\u6cd5\u7b80\u5355\u5206\u6790\u4e00\u4e0b\uff0c\u5177\u4f53\u8bb2\u89e3\u770b\u4ee3\u7801\u4e0a\u9762\u7684\u6ce8\u91ca\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">        \/\/\u8fd9\u91cc\u867d\u7136\u4f20\u5165\u7684\u662f0\uff0c\u4f46\u662f\u4e5f\u4f1a\u5728MockHandlerImpl\u7684handle\u65b9\u6cd5\u8c03\u7528\u7684\u65f6\u5019\uff0c\u5305\u88c5\u6210ArgumentMatcher\u5bf9\u8c61\u5b9e\u4f8b\uff0cArgumentMatcher\u6709\u5f88\u591a\u5b50\u7c7b\n        Mockito.verify(mock).get(0);\n        \/\/\u8fd9\u91cc\u4e00\u5b9a\u4e0d\u8981\u7528any()\u65b9\u6cd5\uff0c\u56e0\u4e3aany\u65b9\u6cd5\u53ea\u9002\u7528\u4e8e\u5bf9\u8c61\u53c2\u6570\uff0c\u800c\u8fd9\u91cc\u5165\u53c2\u662fint\uff0c\u5982\u679c\u4f60\u7528\u4e86any()\uff0c\u90a3\u4e48\u4e00\u5b9a\u4f1a\u62a5\u7a7a\u6307\u9488\n        Mockito.verify(mock).get(ArgumentMatchers.anyInt());\n        \/\/\u8fd9\u79cd\u5199\u6cd5\u548c\u7b2c\u4e00\u79cd\u6bd4\u8f83\u76f8\u4f3c\uff0c\u4f46\u662f\u6709\u4e2a\u597d\u5904\u5c31\u662f\u591a\u4e2a\u5165\u53c2\u7684\u65f6\u5019\uff0c\u7528\u8d77\u6765\u5f88\u65b9\u4fbf\u3002\n        \/\/\u4e3e\u4e2a\u4f8b\u5b50\uff1a\u5165\u53c23\u4e2a\uff0c\u524d2\u4e2a\u9700\u8981\u9a8c\u8bc1\uff0c\u7b2c3\u4e2a\u4e0d\u9700\u8981\u9a8c\u8bc1\uff0c\u90a3\u4e48\u4e45\u5c31\u53ef\u4ee5\u8fd9\u6837\u5199method(ArgumentMatchers.eq(\"\u9700\u8981\u9a8c\u8bc1\u7684\u503c1\"), ArgumentMatchers.eq(\"\u9700\u8981\u9a8c\u8bc1\u7684\u503c2\"), any())\n        Mockito.verify(mock).get(ArgumentMatchers.eq(0));\n        \/\/\u4e0a\u9762\u4f7f\u7528\u7684eq\u3001anyInt\u7b49\u90fd\u662f\u6846\u67b6\u5e2e\u6211\u4eec\u5c01\u88c5\u597d\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u8fdb\u884c\u81ea\u5b9a\u4e49\uff0c\u90a3\u4e48\u4e45\u9700\u8981\u6211\u4eec\u81ea\u5df1\u4f20\u5165ArgumentMatcher\u63a5\u53e3\u5b9e\u73b0\u7c7b\uff0c\u5e76\u91cd\u5199matches\u65b9\u6cd5\u3002\n        \/\/\u5728\u8fdb\u884c\u9a8c\u8bc1\u6bd4\u8f83\u7684\u65f6\u5019\uff0c\u4f1a\u5206\u522b\u5224\u65admock\u5bf9\u8c61\u662f\u5426\u76f8\u540c\u3001\u65b9\u6cd5\u540d\u79f0\u548c\u5165\u53c2\u7c7b\u578b\u662f\u5426\u4e00\u81f4\u3001\u8fd8\u6709\u5c31\u662f\u8c03\u7528ArgumentMatcher\u5b9e\u73b0\u7c7b\u7684matches\u65b9\u6cd5\u5224\u65ad\u5165\u53c2\u503c\u662f\u5426\u4e00\u81f4\n        Mockito.verify(mock).get(ArgumentMatchers.intThat(argument -> true));\n        Mockito.verify(mock).remove(ArgumentMatchers.argThat(argument -> true));<\/pre>\n\n\n\n<p><strong>\u516d\u3001\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u603b\u7684\u6765\u770bMockito\u6e90\u7801\u8bbe\u8ba1\u8fd8\u662f\u633a\u5de7\u7684\uff0c\u8ba9\u4f7f\u7528\u5c31\u5c31\u50cf\u8bf4\u8bdd\u4e00\u6837\u53bb\u5199\u5355\u5143\u6d4b\u8bd5\uff0c\u7b26\u5408\u5e38\u4eba\u7684\u601d\u7ef4\u903b\u8f91\u3002\u5176\u4e2d\u4e5f\u6709\u9ed1\u79d1\u6280ByteBuddy\u4e0eObjenesis\u7684\u5f3a\u52bf\u52a0\u76df\uff0c\u4ee5\u53ca\u591a\u6570\u6846\u67b6\u4f7f\u7528\u7684ThreadLocal\u3002\u6700\u91cd\u8981\u7684\u4ee3\u7801\u5c31\u662fMockHandlerImpl\u7684handle\u65b9\u6cd5\u4e86\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u903b\u8f91\u975e\u5e38\u591a\uff0c\u867d\u7136\u4ee3\u7801\u90fd\u662f\u51fa\u73b0\u5728\u540c\u4e00\u65b9\u6cd5\u5185\uff0c\u4f46\u4ed6\u4eec\u5e76\u4e0d\u662f\u90fd\u5728\u540c\u4e00\u65f6\u7a7a\u5de5\u4f5c\u7684\uff0c\u6709\u4e9b\u4ee3\u7801\u89c6\u4e3awhen\u670d\u52a1\u7684\uff0c\u6709\u4e9b\u89c6\u4e3averify\u670d\u52a1\u7684\uff0c\u8fd8\u6709\u4e3adoReturn\u670d\u52a1\u7684\u3002\u7ecf\u8fc7\u6e90\u7801\u7684\u5206\u6790\uff0c\u76f8\u4fe1\u8bfb\u8005\u5c31\u66f4\u7406\u89e3Mockito\u6846\u67b6\u7684\u5b9e\u73b0\u539f\u7406\u4e86\uff0c\u6b63\u56e0\u4e3a\u6709\u4e86\u5982\u6b64\u5de7\u5999\u7684\u5b9e\u73b0\uff0c\u624d\u652f\u6491\u6211\u4eec\u5199\u51fa\u5e72\u51c0\u6574\u6d01\u7684\u5355\u5143\u6d4b\u8bd5\u3002<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001Mockito\u6e90\u7801\u903b\u8f91\u7b80\u4ecb Mockito\u662f\u4e00\u4e2aMock\u6846\u67b6\uff0c\u8ba9\u4f60\u7528\u7b80\u5355\u5e72\u51c0\u7684API\u5199\u6f02\u4eae\u7684\u6d4b\u8bd5\u4ee3\u7801\u3002Mo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/9939"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9939"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/9939\/revisions"}],"predecessor-version":[{"id":9942,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/9939\/revisions\/9942"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}