{"id":42,"date":"2026-03-12T10:00:00","date_gmt":"2026-03-12T02:00:00","guid":{"rendered":"http:\/\/localhost:8888\/?p=42"},"modified":"2026-07-09T16:17:45","modified_gmt":"2026-07-09T08:17:45","slug":"mock%e6%9c%8d%e5%8a%a1%e5%ae%9e%e6%88%98%e5%85%a8%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/blog.runnergo.cn\/?p=42","title":{"rendered":"Mock\u670d\u52a1\u5b9e\u6218\u5168\u89e3 &#8211; \u4eceWireMock\u5230\u81ea\u5efaMock\u5e73\u53f0"},"content":{"rendered":"<h1>Mock\u670d\u52a1\u5b9e\u6218\u5168\u89e3 &#8211; \u4eceWireMock\u5230\u81ea\u5efaMock\u5e73\u53f0<\/h1>\n<p>&gt; \u4f5c\u8005\uff1a\u540e\u7aef\u6d4b\u5f00<br \/>\n&#8212;<\/p>\n<h2>\u524d\u8a00<\/h2>\n<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f\u540e\u7aef\u6d4b\u5f00\u3002\u505a\u63a5\u53e3\u6d4b\u8bd55\u5e74\uff0cMock\u670d\u52a1\u662f\u89e3\u51b3\u5916\u90e8\u4f9d\u8d56\u7684\u5173\u952e\u5de5\u5177\u3002\u4eca\u5929\u5206\u4eabMock\u670d\u52a1\u7684\u5b9e\u6218\u7ecf\u9a8c\u3002<\/p>\n<p>&#8212;<\/p>\n<h2>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9700\u8981Mock\uff1f<\/h2>\n<h3>\u4f9d\u8d56\u95ee\u9898<\/h3>\n<p>\u63a5\u53e3\u6d4b\u8bd5\u5e38\u89c1\u4f9d\u8d56\u95ee\u9898\uff1a<\/p>\n<ul>\n<li>\u7b2c\u4e09\u65b9\u63a5\u53e3\u4e0d\u7a33\u5b9a<\/li>\n<li>\u5f00\u53d1\u7684\u63a5\u53e3\u8fd8\u6ca1\u5b8c\u6210<\/li>\n<li>\u6d4b\u8bd5\u7279\u5b9a\u54cd\u5e94\u573a\u666f\uff08\u5982\u8d85\u65f6\u3001\u9519\u8bef\uff09<\/li>\n<\/ul>\n<h3>Mock\u7684\u4ef7\u503c<\/h3>\n<p>| \u573a\u666f | Mock\u4ef7\u503c |<br \/>\n|&#8212;&#8212;|&#8212;&#8212;&#8212;-|<br \/>\n| \u63a5\u53e3\u672a\u5b8c\u6210 | \u524d\u7aef\u8054\u8c03\u3001\u6d4b\u8bd5\u8bbe\u8ba1\u5e76\u884c |<br \/>\n| \u7b2c\u4e09\u65b9\u4f9d\u8d56 | \u72ec\u7acb\u6d4b\u8bd5\u3001\u6392\u9664\u5e72\u6270 |<br \/>\n| \u5f02\u5e38\u6d4b\u8bd5 | \u6a21\u62df\u8d85\u65f6\u3001\u9519\u8bef\u3001\u8fb9\u754c\u503c |<\/p>\n<p>&#8212;<\/p>\n<h2>\u4e8c\u3001WireMock\u5165\u95e8<\/h2>\n<h3>\u542f\u52a8WireMock<\/h3>\n<p><code>`<\/code>bash<\/p>\n<h1>Docker\u542f\u52a8<\/h1>\n<p>docker run -d -p 8080:8080 wiremock\/wiremock<\/p>\n<h1>\u4e0b\u8f7d\u542f\u52a8<\/h1>\n<p>java -jar wiremock-standalone.jar<br \/>\n<code>`<\/code><\/p>\n<h3>\u914d\u7f6eMock\u54cd\u5e94<\/h3>\n<p><code>`<\/code>json<br \/>\n{<br \/>\n    &#8220;request&#8221;: {<br \/>\n        &#8220;method&#8221;: &#8220;GET&#8221;,<br \/>\n        &#8220;urlPath&#8221;: &#8220;\/api\/users&#8221;<br \/>\n    },<br \/>\n    &#8220;response&#8221;: {<br \/>\n        &#8220;status&#8221;: 200,<br \/>\n        &#8220;jsonBody&#8221;: {<br \/>\n            &#8220;code&#8221;: 200,<br \/>\n            &#8220;data&#8221;: [<br \/>\n                {&#8220;id&#8221;: 1, &#8220;name&#8221;: &#8220;Mock\u7528\u62371&#8221;},<br \/>\n                {&#8220;id&#8221;: 2, &#8220;name&#8221;: &#8220;Mock\u7528\u62372&#8221;}<br \/>\n            ]<br \/>\n        },<br \/>\n        &#8220;headers&#8221;: {<br \/>\n            &#8220;Content-Type&#8221;: &#8220;application\/json&#8221;<br \/>\n        }<br \/>\n    }<br \/>\n}<br \/>\n<code>`<\/code><\/p>\n<p>&#8212;<\/p>\n<h2>\u4e09\u3001RunnerGo Mock\u529f\u80fd<\/h2>\n<p>RunnerGo\u5185\u7f6eMock\u670d\u52a1\uff0c\u652f\u6301\uff1a<\/p>\n<ul>\n<li>\u81ea\u5b9a\u4e49\u54cd\u5e94<\/li>\n<li>\u52a8\u6001\u6570\u636e\u751f\u6210<\/li>\n<li>\u6761\u4ef6\u5339\u914d<\/li>\n<\/ul>\n<p>&#8212;<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>Mock\u670d\u52a1\u8981\u70b9\uff1a<\/p>\n<p>| \u5de5\u5177 | \u7279\u70b9 |<br \/>\n|&#8212;&#8212;|&#8212;&#8212;|<br \/>\n| WireMock | Java\u751f\u6001\u3001\u72ec\u7acb\u90e8\u7f72 |<br \/>\n| RunnerGo | \u5185\u7f6e\u96c6\u6210\u3001\u53ef\u89c6\u5316\u914d\u7f6e |<\/p>\n<p>&#8212;<\/p>\n<p><strong>\u4e0b\u671f\u9884\u544a\uff1a\u6d4b\u8bd5\u5de6\u79fb\u5b9e\u8df5\u6307\u5357 &#8211; \u5982\u4f55\u5728\u9700\u6c42\u9636\u6bb5\u5c31\u5f00\u59cb\u8d28\u91cf\u4fdd\u969c<\/strong><\/p>\n<p>&gt; \u4f5c\u8005\uff1a\u540e\u7aef\u6d4b\u5f00\uff0c5\u5e74\u63a5\u53e3\u6d4b\u8bd5\u7ecf\u9a8c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mock\u670d\u52a1\u5b9e\u6218\u5168\u89e3 &#8211; \u4eceWireMock\u5230\u81ea\u5efaMock\u5e73\u53f0 &gt; \u4f5c\u8005\uff1a\u540e\u7aef\u6d4b\u5f00 &#8212; \u524d\u8a00 \u5927\u5bb6\u597d\uff0c\u6211\u662f\u540e\u7aef\u6d4b\u5f00\u3002\u505a\u63a5\u53e3\u6d4b\u8bd55\u5e74\uff0cMock\u670d\u52a1\u662f\u89e3\u51b3\u5916\u90e8\u4f9d\u8d56\u7684\u5173\u952e\u5de5\u5177\u3002&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42"}],"version-history":[{"count":0,"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.runnergo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}