{"id":85,"date":"2026-08-15T22:55:56","date_gmt":"2026-08-15T14:55:56","guid":{"rendered":"https:\/\/www.deartester.com\/index.php\/2026\/09\/01\/%e5%89%8d%e5%90%8e%e7%ab%af%e6%b2%a1%e8%81%94%e8%b0%83%e5%b0%b1%e5%b9%b2%e7%ad%89%ef%bc%9f-wiremock%e8%87%aa%e5%b7%b1%e9%80%a0%e6%8e%a5%e5%8f%a3%ef%bc%8c%e6%b5%8b%e8%af%95%e4%b8%8d%e7%94%a8%e7%ad%89\/"},"modified":"2026-09-03T23:17:14","modified_gmt":"2026-09-03T15:17:14","slug":"%e5%89%8d%e5%90%8e%e7%ab%af%e6%b2%a1%e8%81%94%e8%b0%83%e5%b0%b1%e5%b9%b2%e7%ad%89%ef%bc%9f-wiremock%e8%87%aa%e5%b7%b1%e9%80%a0%e6%8e%a5%e5%8f%a3%ef%bc%8c%e6%b5%8b%e8%af%95%e4%b8%8d%e7%94%a8%e7%ad%89","status":"publish","type":"post","link":"https:\/\/www.deartester.com\/index.php\/2026\/08\/15\/%e5%89%8d%e5%90%8e%e7%ab%af%e6%b2%a1%e8%81%94%e8%b0%83%e5%b0%b1%e5%b9%b2%e7%ad%89%ef%bc%9f-wiremock%e8%87%aa%e5%b7%b1%e9%80%a0%e6%8e%a5%e5%8f%a3%ef%bc%8c%e6%b5%8b%e8%af%95%e4%b8%8d%e7%94%a8%e7%ad%89\/","title":{"rendered":"\u524d\u540e\u7aef\u6ca1\u8054\u8c03\u5c31\u5e72\u7b49\uff1f WireMock\u81ea\u5df1\u9020\u63a5\u53e3\uff0c\u6d4b\u8bd5\u4e0d\u7528\u7b49\u5f00\u53d1"},"content":{"rendered":"<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">\u5f15<\/span><\/span><span leaf=\"\" style=\"font-size: 21px;line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\">\u8a00<\/span><\/h2>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4f60\u6709\u6ca1\u6709\u9047\u5230\u8fc7\u8fd9\u79cd\u5c40\u9762\uff1f\u5468\u4e09\u4e0a\u5348\uff0c\u540e\u7aef\u540c\u5b66\u5728\u7fa4\u91cc\u4e22\u4e00\u53e5\uff1a&#8221;\u767b\u5f55\u63a5\u53e3\u5468\u4e94\u624d\u80fd\u7ed9\uff0c\u518d\u7b49\u7b49\u3002&#8221;\u4f60\u6253\u5f00\u6d4b\u8bd5\u8ba1\u5212\u8868\uff0c\u5468\u4e00\u5468\u4e8c\u5df2\u7ecf\u7a7a\u4e86\u4e24\u5929<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u773c\u770b\u7740\u8fed\u4ee3\u5468\u671f\u4e00\u5929\u5929\u903c\u8fd1\uff0c\u4f60\u5374\u53ea\u80fd\u5bf9\u7740\u7a7a\u767d\u7684\u7528\u4f8b\u5e72\u5750\u7740\u3002\u524d\u7aef\u5361\u5728\u8054\u8c03\uff0c\u540e\u7aef\u5361\u5728\u81ea\u6d4b\uff0c\u6d4b\u8bd5\u5361\u5728&#8221;\u6ca1\u4e1c\u897f\u53ef\u6d4b&#8221;\u3002\u4e09\u65b9\u4e92\u76f8\u5e72\u7b49\uff0c\u65f6\u95f4\u5c31\u8fd9\u4e48\u6d41\u8d70\u4e86<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5176\u5b9e\u65b9\u6848\u4e00\u76f4\u5c31\u5728\u624b\u8fb9\u2014\u2014Mock\u3002\u4f46\u8bf7\u6ce8\u610f\uff0cMock \u4ece\u6765\u4e0d\u662f&#8221;\u9020\u5047\u6570\u636e&#8221;\u8fd9\u4e48\u7b80\u5355\u3002\u5b83\u7684\u6838\u5fc3\u4ef7\u503c\u662f<\/span><strong><span leaf=\"\">\u89e3\u9664\u4f9d\u8d56<\/span><\/strong><span leaf=\"\">\u3002\u5f53\u540e\u7aef\u63a5\u53e3\u8fd8\u6ca1\u5c31\u7eea\uff0c\u4f60\u7528 Mock \u628a\u5951\u7ea6\u5c42\u5148\u642d\u8d77\u6765\uff0c\u6d4b\u8bd5\u6d3b\u52a8\u5c31\u80fd\u72ec\u7acb\u5f80\u524d\u63a8\u8fdb<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4eca\u5929\u8981\u804a\u7684 WireMock\uff0c\u5c31\u662f\u4e00\u4e2a\u53ef\u7f16\u7a0b\u7684 HTTP \u6a21\u62df\u670d\u52a1\u5668\u3002\u5b83\u4e0d\u4f9d\u8d56\u4efb\u4f55\u5916\u90e8\u670d\u52a1\uff0c\u8dd1\u5728\u672c\u5730\u6216\u5bb9\u5668\u91cc\uff0c\u6309\u4f60\u5b9a\u4e49\u7684\u89c4\u5219\uff0c\u5bf9\u6bcf\u4e00\u6b21\u8bf7\u6c42\u8fd4\u56de\u4f60\u8bbe\u5b9a\u7684\u54cd\u5e94\u3002\u540e\u7aef\u6ca1\u4ea4\u4ed8\uff1f\u6ca1\u5173\u7cfb\uff0c\u4f60\u81ea\u5df1\u9020\u4e00\u4e2a\u63a5\u53e3\u5148\u7528\u7740<\/span><\/p>\n<section class=\"mp_common_product_iframe_wrp\" nodeleaf=\"\"><mp-common-product data-windowproduct=\"v1=HII_ABVie8kkcW9WRUrMX5F9qYQu8tIur3Us0ySODh_WsGpIuBNpDcYb2E0FedGFPRiKZ2t-23ad2A\" data-cardtype=\"1\" data-title=\"\u53ef\u53e3\u53ef\u4e50\u6b63\u54c1300mlx6\u74f6\u5c0f\u74f6\u88c5\u8ff7\u4f60\u996e\u6599\" data-type=\"0\"><\/mp-common-product><\/section>\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"576\">\n<p data-pm-slice=\"0 0 []\" style=\"text-align: center;\"><span leaf=\"\">\u270d&nbsp;<span textstyle=\"\" style=\"font-size: 16px;color: rgb(123, 12, 0);font-weight: bold;\">\u6211\u7684\u7ecf\u5386\uff1a\u8fd9\u6761\u89c4\u77e9\u6539\u53d8\u4e86\u6574\u4e2a\u56e2\u961f\u8282\u594f<\/span><\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u521a\u5e26\u6d4b\u8bd5\u56e2\u961f\u90a3\u51e0\u5e74\uff0c\u6700\u6015\u6392\u671f\u4f1a\u4e0a\u90a3\u53e5&#8221;\u63a5\u53e3\u8fd8\u5f97\u4e24\u5468&#8221;\u3002\u4e24\u5468\u91cc\u6d4b\u8bd5\u505a\u4ec0\u4e48\uff1f\u624b\u5de5\u70b9\u65e7\u7248\u672c\uff1f\u90a3\u6d4b\u51fa\u6765\u7684\u4e1c\u897f\u8ddf\u65b0\u9700\u6c42\u5bf9\u4e0d\u4e0a\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u540e\u6765\u6211\u8ddf\u56e2\u961f\u5b9a\u4e86\u4e00\u6761\u89c4\u77e9\uff1a<\/span><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: #0052ff;\">\u9700\u6c42\u8bc4\u5ba1\u4e00\u7ed3\u675f\uff0c\u6d4b\u8bd5\u5c31\u6839\u636e\u63a5\u53e3\u6587\u6863\u628a Mock \u642d\u8d77\u6765<\/span>\u3002<\/span><\/strong><span leaf=\"\">\u7b49\u5f00\u53d1\u628a\u771f\u63a5\u53e3\u63d0\u4e0a\u6765\uff0c\u6211\u4eec\u7684\u7528\u4f8b\u65e9\u8dd1\u8fc7\u4e09\u8f6e\u4e86\u3002\u524d\u540e\u7aef\u8054\u8c03\u90a3\u5929\uff0c\u53cd\u800c\u6210\u4e86\u8f7b\u677e\u7684\u4e00\u5929\u2014\u2014\u5951\u7ea6\u5df2\u7ecf\u5728\u7528\u771f\u5b9e\u63a5\u53e3\u9a8c\u8bc1\u4e00\u904d\u4e86\uff0c\u6709\u4ec0\u4e48\u95ee\u9898\u5f53\u573a\u53d1\u73b0\u5f53\u573a\u6539\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9\u6761\u89c4\u77e9\u540e\u6765\u6210\u4e86\u56e2\u961f\u7684\u9ed8\u8ba4\u5de5\u4f5c\u6d41\u3002\u65b0\u4eba\u5165\u804c\u7b2c\u4e00\u5468\u5c31\u4f1a\u95ee\uff1a&#8221;Mock \u642d\u4e86\u5417\uff1f&#8221;\u5927\u5bb6\u6162\u6162\u610f\u8bc6\u5230\uff0c\u6d4b\u8bd5\u4e0d\u662f\u7b49\u5f00\u53d1\u7ed9\u4e1c\u897f\uff0c\u800c\u662f\u4e3b\u52a8\u53bb\u63a5\u4e1c\u897f\u3002<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">01<\/span><\/span><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">WireMock\u662f\u4ec0\u4e48\uff1a\u4e00\u4e2a&#8221;\u542c\u8bdd\u7684\u6f14\u5458&#8221;<\/span><\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">1.1 \u6838\u5fc3\u6982\u5ff5\uff1aStub \u4e0e Mapping<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u628a WireMock \u60f3\u8c61\u6210\u5267\u573a\u91cc\u4e00\u4f4d\u7279\u522b\u542c\u8bdd\u7684\u6f14\u5458\u3002\u4f60\u7ed9\u4ed6\u4e00\u4efd&#8221;\u5267\u672c&#8221;\uff0c\u4ed6\u5c31\u7167\u7740\u6f14\u3002\u8fd9\u4efd\u5267\u672c\uff0c\u5728 WireMock \u91cc\u53eb&nbsp;<\/span><strong><span leaf=\"\">Stub\uff08\u5b58\u6839\uff09<\/span><\/strong><span leaf=\"\">\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4e00\u4e2a Stub \u63cf\u8ff0\u4e86\u4e00\u4ef6\u4e8b\uff1a\u5f53\u6536\u5230\u67d0\u79cd\u8bf7\u6c42\u65f6\uff0c\u8fd4\u56de\u67d0\u79cd\u54cd\u5e94\u3002\u6bd4\u5982&#8221;\u6536\u5230 POST \/api\/login\uff0c\u5c31\u8fd4\u56de 200 \u548c\u4e00\u6bb5 token&#8221;\u3002\u8bf7\u6c42\u957f\u4ec0\u4e48\u6837\u3001\u54cd\u5e94\u957f\u4ec0\u4e48\u6837\uff0c\u5168\u90e8\u7531\u4f60\u5199\u6b7b\uff0c\u6216\u52a8\u6001\u751f\u6210\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u90a3\u4e48&nbsp;<\/span><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">Mapping\uff08\u6620\u5c04\uff09<\/span><\/span><\/strong><span leaf=\"\">&nbsp;\u53c8\u662f\u4ec0\u4e48\uff1f\u5b83\u662f\u4e00\u7ec4 Stub \u7684\u96c6\u5408\uff0c\u901a\u5e38\u5bf9\u5e94\u4e00\u4e2a JSON \u6587\u4ef6\u3002\u4f60\u5728 mappings \u76ee\u5f55\u4e0b\u653e\u4e00\u4e2a login.json\uff0c\u91cc\u9762\u5b9a\u4e49\u597d\u767b\u5f55\u76f8\u5173\u7684 Stub\uff0cWireMock \u542f\u52a8\u65f6\u5c31\u4f1a\u52a0\u8f7d\u5b83\u3002<\/span><\/p>\n<p style=\"text-indent: 2em;\"><span leaf=\"\">\u53ef\u4ee5\u7406\u89e3\u4e3a\uff1aStub \u662f\u5355\u6761\u89c4\u5219\uff0cMapping \u662f\u88c5\u8fd9\u4e9b\u89c4\u5219\u7684&#8221;\u6587\u4ef6\u62bd\u5c49&#8221;\u3002\u4e00\u4e2a\u6587\u4ef6\u91cc\u80fd\u653e\u591a\u4e2a Stub\uff0c\u6309\u4f18\u5148\u7ea7\u548c\u5339\u914d\u5ea6\u4f9d\u6b21\u5c1d\u8bd5\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-style: italic;\">\u4f60\u53ef\u80fd\u4f1a\u95ee\uff0c\u591a\u4e2a Stub \u90fd\u5339\u914d\u540c\u4e00\u4e2a\u8bf7\u6c42\u600e\u4e48\u529e\uff1fWireMock \u6709\u4e00\u5957\u4f18\u5148\u7ea7\u673a\u5236\u3002\u6bcf\u4e2a Stub \u53ef\u4ee5\u8bbe priority\uff0c\u6570\u5b57\u8d8a\u5c0f\u8d8a\u4f18\u5148\uff1b\u4f18\u5148\u7ea7\u76f8\u540c\u65f6\u6309\u5339\u914d\u7cbe\u786e\u5ea6\u6392\u5e8f\uff0c\u5339\u914d\u7ef4\u5ea6\u8d8a\u591a\u8d8a\u7cbe\u786e\u3002\u7406\u89e3\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u4e0d\u7136\u4f60\u5199\u591a\u4e86 Stub \u5c31\u4f1a\u53d1\u73b0&#8221;\u4e3a\u4ec0\u4e48\u603b\u547d\u4e2d\u90a3\u4e2a\u4e0d\u662f\u6211\u60f3\u8981\u7684&#8221;\u3002\u6240\u4ee5\u5199 Mock \u548c\u5199\u7528\u4f8b\u4e00\u6837\uff0c\u7ea6\u675f\u8981\u5199\u5168\uff0c\u522b\u7559\u6a21\u7cca\u5730\u5e26\u3002<\/span><\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">1.2 \u4e09\u79cd\u8fd0\u884c\u6a21\u5f0f<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">WireMock \u63d0\u4f9b\u4e86\u4e09\u79cd\u5e38\u89c1\u8dd1\u6cd5\uff0c\u9002\u5e94\u4e0d\u540c\u573a\u666f\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\" style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-weight: bold;\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">\u65b9\u5f0f\u4e00\u662f<\/span><\/span><span leaf=\"\">&nbsp;<\/span><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">Standalone\uff08\u547d\u4ee4\u884c\uff09<\/span><\/span><\/strong><span leaf=\"\">\u3002\u4f60\u4e0b\u8f7d\u4e00\u4e2a\u72ec\u7acb jar \u5305\uff0c\u6572\u4e00\u6761 java -jar \u547d\u4ee4\u5c31\u80fd\u8d77\u670d\u52a1\u3002\u9002\u5408\u672c\u5730\u5feb\u901f\u9a8c\u8bc1\uff0c\u968f\u624b\u5c31\u80fd\u7528\uff0c\u4e0d\u63ba\u548c\u4efb\u4f55\u5bb9\u5668\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\" style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-weight: bold;\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">\u65b9\u5f0f\u4e8c\u662f<\/span><\/span><span leaf=\"\">&nbsp;<\/span><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">Docker\uff08\u5bb9\u5668\u5316\uff09<\/span><\/span><\/strong><span leaf=\"\">\u3002\u62c9\u5b98\u65b9\u955c\u50cf wiremock\/wiremock\uff0c\u4e00\u6761 docker run \u628a\u670d\u52a1\u8dd1\u5728\u5bb9\u5668\u91cc\u3002\u597d\u5904\u662f\u73af\u5883\u5e72\u51c0\u3001\u53ef\u590d\u7528\u3001\u65b9\u4fbf\u56e2\u961f\u5171\u4eab\u540c\u4e00\u5957 Mock \u914d\u7f6e\u3002\u8fd9\u4e5f\u662f\u6211\u5728\u56e2\u961f\u91cc\u63a8\u8350\u7684\u505a\u6cd5\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\" style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-weight: bold;\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">\u65b9\u5f0f\u4e09\u662f<\/span><\/span><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">&nbsp;<\/span><\/span><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(123, 12, 0);\">\u5d4c\u5165\u5f0f\uff08Embedded\uff09<\/span><\/span><\/strong><span leaf=\"\">\u3002\u5728 Java \u9879\u76ee\u91cc\u901a\u8fc7\u4f9d\u8d56\u628a WireMock \u5d4c\u8fdb\u53bb\uff0c\u968f\u6d4b\u8bd5\u4e00\u8d77\u542f\u52a8\u548c\u9500\u6bc1\u3002\u9002\u5408\u5199 Java \u96c6\u6210\u6d4b\u8bd5\u7684\u540c\u5b66\uff0c\u8ddf JUnit \u914d\u5408\u5f97\u5f88\u987a\u3002<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">1.3 \u548c Postman Mock \u7684\u533a\u522b<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #407600;\">\u5f88\u591a\u540c\u5b66\u5e38\u89c1\u53cd\u5e94\u662f\uff1a&#8221;Postman \u4e0d\u662f\u4e5f\u80fd Mock \u5417\uff1f&#8221;\u80fd\uff0c\u4f46\u5dee\u522b\u5f88\u5927<\/span><\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"text-decoration: underline;\">Postman Mock \u9700\u8981\u767b\u5f55\u8d26\u53f7\u3001\u4f9d\u8d56\u4e91\u7aef\uff0c\u914d\u7f6e\u5206\u6563\u5728\u4e2a\u4eba\u5de5\u4f5c\u533a\u91cc\uff0c\u56e2\u961f\u534f\u4f5c\u65f6\u5bb9\u6613\u5404\u641e\u5404\u7684\u3002\u66f4\u5173\u952e\u7684\u662f\uff0c\u5b83\u4e0d\u652f\u6301\u72b6\u6001\u7ba1\u7406\u2014\u2014\u4f60\u6ca1\u6cd5\u8ba9\u540c\u4e00\u4e2a\u63a5\u53e3\u5728\u4e0d\u540c\u8c03\u7528\u6b21\u6570\u4e0b\u8fd4\u56de\u4e0d\u540c\u7ed3\u679c<\/span><\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5b83\u4e5f\u4e0d\u652f\u6301\u6545\u969c\u6ce8\u5165\uff0c\u60f3\u6a21\u62df\u4e00\u4e2a 500 \u9519\u8bef\uff0c\u5f97\u624b\u52a8\u6539\u914d\u7f6e\u3002WireMock \u5b8c\u5168\u672c\u5730\u8fd0\u884c\uff0c\u4e0d\u7ed1\u5b9a\u4efb\u4f55\u8d26\u53f7\u3002\u5b83\u652f\u6301\u72b6\u6001\u673a\uff08Scenarios\uff09\uff0c\u80fd\u8ba9\u63a5\u53e3\u6309\u6b65\u9aa4\u5207\u6362\u54cd\u5e94\uff1b\u652f\u6301\u5ef6\u8fdf\u6ce8\u5165\uff0c\u80fd\u6a21\u62df\u6162\u63a5\u53e3\uff1b\u652f\u6301\u968f\u673a\u3001\u4ee3\u7406\u3001\u4f18\u5148\u7ea7\u5339\u914d\u7b49\u73a9\u6cd5<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u518d\u8865\u4e00\u53e5<\/span>\uff1a\u6709\u4eba\u4f1a\u62ff WireMock \u8ddf\u5355\u5143\u6d4b\u8bd5\u91cc\u7684 Mock \u6846\u67b6\u6bd4\u3002\u90a3\u662f\u4e24\u4e2a\u5c42\u9762\u3002Mock \u6846\u67b6\uff08\u6bd4\u5982 Java \u7684 Mockito\uff09Mock \u7684\u662f\u4ee3\u7801\u91cc\u7684\u5bf9\u8c61\uff0c\u8dd1\u5728\u8fdb\u7a0b\u5185\uff1bWireMock Mock \u7684\u662f HTTP \u670d\u52a1\uff0c\u8fdb\u7a0b\u5916\u3001\u8de8\u8bed\u8a00\u3002\u524d\u7aef\u9875\u9762\u3001\u6d4b\u8bd5\u811a\u672c\u3001\u522b\u7684\u8bed\u8a00\u5199\u7684\u670d\u52a1\uff0c\u90fd\u80fd\u76f4\u63a5\u8c03\u5b83\u3002<span textstyle=\"\" style=\"color: #0052ff;text-decoration: underline;\">\u8fd9\u6b63\u662f\u5b83\u9002\u5408\u505a\u63a5\u53e3\u5951\u7ea6\u6d4b\u8bd5\u7684\u6839\u672c\u539f\u56e0\uff1a\u5b83\u7ad9\u5728\u771f\u5b9e\u7684\u7f51\u7edc\u534f\u8bae\u5c42\uff0c\u800c\u4e0d\u662f\u4ee3\u7801\u5c42<\/span><\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">1.4 \u9002\u7528\u4eba\u7fa4<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u8c01\u4f1a\u7528\u5f97\u4e0a\uff1f<\/span><\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\">\u63a5\u53e3\u6d4b\u8bd5\u5de5\u7a0b\u5e08<\/span><\/strong><span leaf=\"\">\uff1a\u4e0d\u7528\u5e72\u7b49\u540e\u7aef\uff0c\u63d0\u524d\u628a\u5951\u7ea6\u6d4b\u5b8c\u3002<\/span><strong><span leaf=\"\">\u524d\u7aef\u5f00\u53d1<\/span><\/strong><span leaf=\"\">\uff1a\u63a5\u53e3\u6ca1\u597d\u4e5f\u80fd\u8c03\u9875\u9762\uff0c\u8054\u8c03\u6548\u7387\u7ffb\u500d\u3002<\/span><strong><span leaf=\"\">\u5fae\u670d\u52a1\u6d4b\u8bd5<\/span><\/strong><span leaf=\"\">\uff1a\u5728\u590d\u6742\u8c03\u7528\u94fe\u91cc\uff0c\u628a\u4e0b\u6e38\u670d\u52a1\u5168\u90e8 Mock \u6389\uff0c\u4e13\u6ce8\u6d4b\u5f53\u524d\u670d\u52a1\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5982\u679c\u4f60\u5c5e\u4e8e\u8fd9\u4e09\u7c7b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u503c\u5f97\u770b\u5230\u672b\u5c3e\u3002\u987a\u5e26\u8bf4\uff0c\u4e0d\u53ea\u662f\u8fd9\u4e09\u7c7b\u3002\u6027\u80fd\u6d4b\u8bd5\u540c\u5b66\u4e5f\u80fd\u7528 WireMock \u5f53\u7a33\u5b9a\u7684\u4e0b\u6e38\uff0c\u6392\u9664\u88ab\u6d4b\u670d\u52a1\u4e4b\u5916\u7684\u53d8\u91cf\uff1b\u6280\u672f\u6587\u6863\u540c\u5b66\u80fd\u7528\u5b83\u5feb\u901f\u9020\u51fa\u53ef\u6f14\u793a\u7684\u63a5\u53e3\uff1b\u751a\u81f3\u4ea7\u54c1\u7ecf\u7406\u90fd\u80fd\u7528\u5b83\u642d\u4e2a\u80fd\u70b9\u7684 demo \u53bb\u8ddf\u8001\u677f\u6c47\u62a5\u3002\u53ea\u8981\u4f60\u7684\u5de5\u4f5c\u5361\u5728&#8221;\u67d0\u4e2a HTTP \u63a5\u53e3\u8fd8\u6ca1\u597d&#8221;\uff0c\u5b83\u5c31\u6709\u7528\u6b66\u4e4b\u5730\u3002\u95e8\u69db\u4e0d\u9ad8\uff0c\u56de\u62a5\u5374\u4e0d\u5c0f\u3002<\/span><\/p>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000715\" data-ratio=\"0.48703703703703705\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/BWmfcibGhS1IUBVSVfVeVhUgkFh8cVTc7wyFvYm64tTkbpN9oB4eX8oD7DYXQgCwrwPnBrqv2JnhajcO4k1D7w1JjcPEFwnNAfts17w10dib0\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;color: rgb(136, 136, 136);\">WireMock \u6574\u4f53\u67b6\u6784\u2014\u2014\u8bf7\u6c42\u7ecf\u5339\u914d\u5f15\u64ce\u547d\u4e2d Stub\uff0c\u914d\u7f6e\u6587\u4ef6\u7531\u6587\u4ef6\u7cfb\u7edf\u52a0\u8f7d\uff0c\u652f\u6301\u7ba1\u7406\u540e\u53f0\u5b9e\u65f6\u8c03\u8bd5<\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">02<\/span><\/span><span leaf=\"\">Docker\u4e09\u5206\u949f\u642d\u5efaMock\u670d\u52a1<\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">2.1 \u4e00\u6761\u547d\u4ee4\u542f\u52a8<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u7701\u4e8b\u7684\u65b9\u5f0f\u662f Docker\u3002\u786e\u4fdd\u4f60\u7684\u673a\u5668\u88c5\u4e86 Docker\uff0c\u7136\u540e\u6267\u884c\u4e0b\u9762\u8fd9\u6761\u547d\u4ee4\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"apache\"><code><span leaf=\"\"><span class=\"code-snippet__comment\"># \u540e\u53f0\u542f\u52a8 WireMock\uff0c\u628a\u5bb9\u5668 8080 \u7aef\u53e3\u6620\u5c04\u5230\u672c\u673a 8080<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__attribute\">docker<\/span>&nbsp;run -d --name wiremock -p&nbsp;<span class=\"code-snippet__number\">8080<\/span>:<span class=\"code-snippet__number\">8080<\/span>&nbsp;wiremock\/wiremock<\/span><\/code><\/pre>\n<\/section>\n<p style=\"margin: -8px 0px 18px;font-size: 13px;color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: center;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">\u4ee3\u7801 1\uff1adocker run \u4e00\u952e\u62c9\u8d77 WireMock \u670d\u52a1<\/span><\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9\u6761\u547d\u4ee4\u62c9\u53d6\u5b98\u65b9\u955c\u50cf\u5e76\u540e\u53f0\u542f\u52a8\u3002\u51e0\u79d2\u949f\u540e\uff0c\u670d\u52a1\u5c31\u6d3b\u4e86\u3002\u4f60\u53ef\u4ee5\u7528 curl \u6216\u6d4f\u89c8\u5668\u63a2\u4e00\u4e0b http:\/\/localhost:8080 \u770b\u662f\u5426\u5c31\u7eea\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5982\u679c\u60f3\u7528\u72ec\u7acb jar \u800c\u4e0d\u662f Docker\uff0c\u53bb\u5b98\u7f51\u4e0b wiremock-standalone \u7684 jar \u5305\uff0c\u6267\u884c java -jar wiremock-standalone-\u7248\u672c\u53f7.jar &#8211;port 8080 &#8211;verbose \u540c\u6837\u80fd\u8d77\u3002\u4e24\u8005\u5e95\u5c42\u4e00\u81f4\uff0c\u533a\u522b\u53ea\u5728\u8fd0\u884c\u73af\u5883\u3002\u65b0\u624b\u6211\u5efa\u8bae\u4ece Docker \u5165\u624b\uff0c\u5c11\u8e29\u73af\u5883\u5751\uff0c\u5c24\u5176\u662f Windows \u4e0a\u914d Java \u73af\u5883\u53d8\u91cf\u90a3\u4e00\u5957\uff0c\u80fd\u7701\u5219\u7701\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8d77\u5b8c\u670d\u52a1\u540e\uff0c\u987a\u624b\u7528 docker ps \u786e\u8ba4\u5bb9\u5668\u72b6\u6001\u662f Up\uff0c\u518d\u7528 curl http:\/\/localhost:8080\/__admin\/mappings \u770b\u4e00\u773c\u5df2\u52a0\u8f7d\u7684\u6620\u5c04\u5217\u8868\u3002\u5982\u679c\u5217\u8868\u4e3a\u7a7a\uff0c\u8bf4\u660e mappings \u76ee\u5f55\u6ca1\u6302\u5bf9\uff1b\u5982\u679c\u8fde\u4e0d\u4e0a\uff0c\u5148\u67e5\u7aef\u53e3\u662f\u5426\u88ab\u5360\u7528\u3002\u8fd9\u51e0\u4e2a\u547d\u4ee4\u6211\u6bcf\u5929\u90fd\u8981\u6572\uff0c\u719f\u7ec3\u4e4b\u540e\u6392\u9519\u57fa\u672c\u5728\u5341\u79d2\u5185\u5b8c\u6210\u3002<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">2.2 \u8bbf\u95ee\u7ba1\u7406\u540e\u53f0<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u670d\u52a1\u8d77\u6765\u540e\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\u8bbf\u95ee&nbsp;<\/span><code><span leaf=\"\">http:\/\/localhost:8080\/__admin\/<\/span><\/code><span leaf=\"\">\u3002\u8fd9\u662f WireMock \u7684\u7ba1\u7406\u540e\u53f0\uff0c\u7528\u6765\u770b\u5f53\u524d\u52a0\u8f7d\u4e86\u54ea\u4e9b Stub\u3001\u5339\u914d\u4e86\u591a\u5c11\u6b21\u8bf7\u6c42\u3001\u8fd1\u671f\u7684\u8c03\u7528\u65e5\u5fd7\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u540e\u53f0\u91cc\u6709\u4e2a\u529f\u80fd\u6211\u51e0\u4e4e\u5929\u5929\u7528\uff1a\u67e5\u770b\u5355\u4e2a Stub \u7684\u5339\u914d\u6b21\u6570\u548c\u8fd1\u671f\u8bf7\u6c42\u4f53\u3002\u5f53\u4f60\u89c9\u5f97&#8221;\u6211\u660e\u660e\u914d\u4e86\u554a\u600e\u4e48\u6ca1\u8fd4\u56de&#8221;\uff0c\u70b9\u5f00\u8fd1\u671f\u8bf7\u6c42\uff0c\u5f80\u5f80\u53d1\u73b0\u662f\u8bf7\u6c42\u5934\u5c11\u4e86\u4e2a\u5b57\u6bb5\uff0c\u6216 URL \u591a\u5e26\u4e86\u659c\u6760\u3002\u8fd9\u7c7b\u95ee\u9898\u9760\u731c\u534a\u5929\u4e0d\u5982\u770b\u4e00\u773c\u65e5\u5fd7\u3002\u53e6\u5916\uff0c\u540e\u53f0\u8fd8\u80fd\u76f4\u63a5\u589e\u5220\u6539 Stub\uff0c\u7d27\u6025\u8c03\u8bd5\u65f6\u4e0d\u7528\u6539\u6587\u4ef6\u91cd\u542f\uff0c\u5f88\u65b9\u4fbf\u3002<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"576\">\n<p data-pm-slice=\"0 0 []\" style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 16px;\">\u270d&nbsp;<\/span><span textstyle=\"\" style=\"font-size: 16px;color: #7b0c00;font-weight: bold;\">\u4e00\u6b21\u771f\u5b9e\u7684\u6392\u969c\u7ecf\u5386<\/span><\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6709\u4e00\u6b21\u56e2\u961f\u91cc\u7684\u5c0f\u9648\u8ddf\u6211\u8bf4\uff1a&#8221;\u767b\u5f55 Mock \u600e\u4e48\u8c03\u90fd\u4e0d\u901a\uff0c\u4e00\u76f4\u8fd4\u56de 404\u3002&#8221;\u6211\u8fc7\u53bb\u4e00\u770b\uff0c\u4ed6\u914d\u7684\u662f POST \/api\/login\uff0c\u4f46\u5b9e\u9645\u524d\u7aef\u53d1\u7684\u662f POST \/api\/login\/?from=app\u2014\u2014\u591a\u4e86\u4e00\u4e2a query \u53c2\u6570\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4ed6\u7528\u7684\u662f urlPath \u7cbe\u786e\u5339\u914d\uff0c\u4e0d\u4f1a\u5ffd\u7565 query\uff0c\u6240\u4ee5\u4e24\u4e2a\u8bf7\u6c42\u6839\u672c\u4e0d\u662f\u540c\u4e00\u4e2a\u3002\u6211\u8ba9\u4ed6\u628a\u914d\u7f6e\u6539\u6210 urlPath\uff08\u53ea\u5339\u914d\u8def\u5f84\u90e8\u5206\uff09\uff0c\u6216\u8005\u5e72\u8106\u7528 urlPathPattern \u52a0\u6b63\u5219\u6392\u9664 query\uff0c\u95ee\u9898\u7acb\u523b\u89e3\u51b3\u4e86\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u540e\u6765\u6211\u628a\u8fd9\u4ef6\u4e8b\u8bb0\u4e86\u4e0b\u6765\uff0c\u5728\u56e2\u961f code review \u6e05\u5355\u91cc\u52a0\u4e86\u4e00\u6761\uff1a&#8221;urlPath \u8fd8\u662f url\uff1f\u67e5\u6e05\u695a\u518d\u914d\u3002&#8221;\u7c7b\u4f3c\u7684\u5c0f\u5751\u8e29\u8fc7\u4e00\u6b21\uff0c\u540e\u9762\u4e03\u516b\u4e2a\u4eba\u90fd\u8ddf\u7740\u907f\u5f00\u4e86\u3002<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">2.3 \u76ee\u5f55\u7ed3\u6784\u4e0e docker-compose \u6302\u8f7d<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">WireMock \u6709\u4e24\u4e2a\u5173\u952e\u76ee\u5f55\u3002<\/span><code><span leaf=\"\">\/mappings<\/span><\/code><span leaf=\"\">&nbsp;\u653e JSON \u6620\u5c04\u6587\u4ef6\uff0c\u6bcf\u4e2a\u6587\u4ef6\u5b9a\u4e49\u82e5\u5e72 Stub\u3002<\/span><code><span leaf=\"\">\/__files<\/span><\/code><span leaf=\"\">&nbsp;\u653e\u54cd\u5e94\u6a21\u677f\u6216\u9759\u6001\u6587\u4ef6\uff0c\u6bd4\u5982\u4f60\u8981\u8fd4\u56de\u7684 HTML\u3001\u5927\u6bb5 JSON\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u7528 Docker \u65f6\uff0c\u8bb0\u5f97\u628a\u8fd9\u4e24\u4e2a\u76ee\u5f55\u6302\u8f7d\u51fa\u6765\uff0c\u5426\u5219\u5bb9\u5668\u4e00\u5220\uff0c\u4f60\u5199\u7684\u914d\u7f6e\u5168\u6ca1\u4e86\u3002\u7a33\u59a5\u7684\u505a\u6cd5\u662f docker-compose \u6302\u8f7d\u672c\u5730\u76ee\u5f55\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"bash\"><code><span leaf=\"\">version:&nbsp;<span class=\"code-snippet__string\">\"3.8\"<\/span><\/span><\/code><code><span leaf=\"\">services:<\/span><\/code><code><span leaf=\"\">&nbsp; wiremock:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; image: wiremock\/wiremock:latest &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u5b98\u65b9\u955c\u50cf\uff0c\u8ddf\u968f\u7a33\u5b9a\u7248<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; container_name: wiremock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\"># \u5bb9\u5668\u540d\uff0c\u65b9\u4fbf docker \u547d\u4ee4\u5f15\u7528<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; ports:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; -&nbsp;<span class=\"code-snippet__string\">\"8080:8080\"<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\"># \u5bbf\u4e3b\u673a 8080 \u6620\u5c04\u5230\u5bb9\u5668 8080<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; volumes:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - .\/mappings:\/home\/wiremock\/mappings &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6302\u8f7d\u6620\u5c04\u76ee\u5f55\uff0c\u70ed\u52a0\u8f7d Stub<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - .\/__files:\/home\/wiremock\/__files &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6302\u8f7d\u54cd\u5e94\u6587\u4ef6\u76ee\u5f55<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__built_in\">command<\/span>: [<span class=\"code-snippet__string\">\"--verbose\"<\/span>] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\"># \u5f00\u542f\u8be6\u7ec6\u65e5\u5fd7\uff0c\u65b9\u4fbf\u6392\u67e5\u5339\u914d\u5931\u8d25<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-indent: 0px;text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">docker-compose.yml\uff0c\u6302\u8f7d\u672c\u5730\u914d\u7f6e\u5b9e\u73b0\u6301\u4e45\u5316\u4e0e\u70ed\u52a0\u8f7d<\/span><\/span><\/section>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u914d\u4e0a compose \u4e4b\u540e\uff0c\u4f60\u5728\u672c\u5730 mappings \u76ee\u5f55\u91cc\u6539\u6587\u4ef6\uff0cWireMock \u4f1a\u81ea\u52a8\u70ed\u52a0\u8f7d\uff0c\u4e0d\u7528\u91cd\u542f\u5bb9\u5668\u3002\u8fd9\u5bf9\u8fb9\u5199\u8fb9\u8c03\u7684\u8282\u594f\u5f88\u53cb\u597d<\/span><\/p>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">03<\/span><\/span><span leaf=\"\">\u57fa\u7840\u2014\u2014Mock\u9996\u4e2a\u63a5\u53e3<\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">3.1 JSON \u6620\u5c04\u6587\u4ef6<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6211\u4eec\u4eb2\u624b Mock \u9996\u4e2a\u63a5\u53e3\uff1a\u767b\u5f55\u3002\u5728 mappings \u76ee\u5f55\u4e0b\u521b\u5efa login.json\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"json\"><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"request\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"method\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"POST\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u53ea\u5339\u914d POST \u8bf7\u6c42<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"urlPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\/api\/login\"<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u7cbe\u786e\u5339\u914d\u8def\u5f84\uff0c\u5ffd\u7565\u67e5\u8be2\u53c2\u6570<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"response\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"status\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">200<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\">\/\/ \u8fd4\u56de\u72b6\u6001\u7801 200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"headers\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"Content-Type\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"application\/json; charset=utf-8\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"jsonBody\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u76f4\u63a5\u5199 JSON \u4f53\uff0cWireMock \u81ea\u52a8\u5e8f\u5217\u5316<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"code\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">0<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"msg\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"success\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"data\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"token\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"mock-token-2026-abc123\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"userId\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">10086<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"expireIn\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">7200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">login.json\uff0c\u5b9a\u4e49\u4e00\u4e2a\u57fa\u7840\u7684\u767b\u5f55 Stub\uff08\u6807\u51c6 JSON\uff0c\u53ef\u76f4\u63a5\u653e\u5165 mappings \u76ee\u5f55\uff09<\/span><\/span><\/span><\/section>\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"576\">\n<section><span style=\"color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(240, 247, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u8bf4\u660e\uff1a<\/span>WireMock \u6620\u5c04\u6587\u4ef6\u662f\u6807\u51c6 JSON\uff0c\u4e0a\u9762\u6ce8\u91ca\u4ec5\u7528\u4e8e\u8bb2\u89e3\u3002\u5b9e\u9645\u4f7f\u7528\u65f6\u5220\u9664&nbsp;<\/span><\/span><code style=\"color: rgb(52, 73, 94);font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\/\/<\/span><\/code><span style=\"color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(240, 247, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;\"><span leaf=\"\">&nbsp;\u6ce8\u91ca\u5373\u4e3a\u53ef\u8fd0\u884c\u914d\u7f6e\uff1b\u4e0b\u6587 Python \u4ee3\u7801\u5219\u4fdd\u7559<span textstyle=\"\" style=\"font-weight: bold;\">&nbsp;<\/span><\/span><\/span><code style=\"color: rgb(52, 73, 94);font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">#<\/span><\/span><\/code><span style=\"color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(240, 247, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;\"><span leaf=\"\">&nbsp;\u6ce8\u91ca\uff0c\u4e8c\u8005\u5747\u5b8c\u6574\u53ef\u8fd0\u884c\u3002<\/span><\/span><\/section>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u8fd9\u4e2a Stub \u7684\u610f\u601d\u662f\uff1a\u51e1\u662f POST \u5230 \/api\/login \u7684\u8bf7\u6c42\uff0c\u90fd\u8fd4\u56de 200\uff0cbody \u91cc\u5e26\u4e00\u4e2a token\u3002\u6ce8\u610f\u7528\u7684\u662f urlPath \u7cbe\u786e\u5339\u914d\u8def\u5f84\uff0c\u4e0d\u5173\u5fc3\u67e5\u8be2\u53c2\u6570<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9\u91cc\u6709\u4e2a\u7ec6\u8282\u503c\u5f97\u8bb0\uff1aurlPath \u53ea\u6bd4\u8def\u5f84\uff0curl \u6bd4\u5b8c\u6574\u5730\u5740\u542b query\u3002\u5982\u679c\u4f60\u7684\u63a5\u53e3\u9760 query \u53c2\u6570\u533a\u5206\uff0c\u6bd4\u5982 \/api\/list?page=1\uff0c\u7528 urlPath \u4f1a\u5ffd\u7565 page\uff0c\u5bfc\u81f4\u6240\u6709\u5206\u9875\u90fd\u547d\u4e2d\u540c\u4e00\u4e2a Stub\u3002\u9700\u8981\u533a\u5206\u65f6\u5c31\u7528 urlPathPattern \u914d\u5408\u6b63\u5219\uff0c\u6216\u8005\u989d\u5916\u52a0 queryParameters \u5339\u914d<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd8\u6709\u4e2a\u5e38\u89c1\u6df7\u6dc6\uff1aresponse \u91cc\u7528 jsonBody \u8fd8\u662f body\uff1fjsonBody \u8ba9 WireMock \u5e2e\u4f60\u5e8f\u5217\u5316\u5e76\u81ea\u52a8\u52a0 JSON \u5934\uff0c\u5199\u8d77\u6765\u66f4\u5e72\u51c0\uff1bbody \u5219\u662f\u4f60\u81ea\u5df1\u5199\u539f\u59cb\u5b57\u7b26\u4e32\uff0c\u9002\u5408\u8fd4\u56de XML \u6216\u975e\u6807\u51c6\u683c\u5f0f\u3002\u6211\u7684\u7ecf\u9a8c\u662f\uff0c\u53ea\u8981\u8fd4\u56de\u7684\u662f JSON\uff0c\u4e00\u5f8b\u7528 jsonBody\uff0c\u5c11\u51fa\u9519\u3002\u53cd\u4e4b\u8981\u8fd4\u56de\u4e00\u6bb5 HTML \u6216\u7eaf\u6587\u672c\uff0c\u5c31\u7528 body \u914d\u5408\u624b\u52a8\u8bbe\u7f6e\u7684 Content-Type<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">3.2 \u8bf7\u6c42\u5339\u914d\u89c4\u5219<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">WireMock \u7684\u5339\u914d\u89c4\u5219\u5f88\u7075\u6d3b\uff0c\u8fdc\u4e0d\u6b62&#8221;\u8def\u5f84&#8221;\u8fd9\u4e00\u79cd<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\">URL \u5339\u914d<\/span><\/strong><span leaf=\"\">\u6709\u4e24\u79cd\uff1aurl \u7cbe\u786e\u5339\u914d\u5b8c\u6574\u8def\u5f84\uff0curlPath \u5339\u914d\u8def\u5f84\u90e8\u5206\uff08\u5ffd\u7565 query\uff09\u3002\u8fd8\u652f\u6301 urlPathPattern \u7528\u6b63\u5219\u5339\u914d\uff0c\u6bd4\u5982 \/api\/users\/[0-9]+ \u5339\u914d\u4efb\u610f\u7528\u6237 ID<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\">Method \u5339\u914d<\/span><\/strong><span leaf=\"\">\uff1aGET\u3001POST\u3001PUT\u3001DELETE \u4efb\u9009\u3002<\/span><strong><span leaf=\"\">Header \u5339\u914d<\/span><\/strong><span leaf=\"\">\uff1a\u53ef\u4ee5\u6307\u5b9a\u67d0\u4e2a\u8bf7\u6c42\u5934\u5fc5\u987b\u5b58\u5728\u6216\u53d6\u503c\u7b26\u5408\u9884\u671f\uff0c\u6bd4\u5982\u8981\u6c42 Content-Type \u662f application\/json<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\">Body \u5339\u914d<\/span><\/strong><span leaf=\"\">\uff1a\u5f3a\u5927\u7684\u662f JSONPath \u548c XPath\u3002\u4f60\u53ef\u4ee5\u5199 &#8220;$.username&#8221; \u53bb\u5339\u914d\u8bf7\u6c42\u4f53\u91cc\u7684\u67d0\u4e2a\u5b57\u6bb5\uff0c\u5b9e\u73b0&#8221;\u4e0d\u540c username \u8fd4\u56de\u4e0d\u540c\u7ed3\u679c&#8221;\u3002\u8fd9\u4e00\u62db\u5728\u7b2c\u56db\u7ae0\u4f1a\u5927\u663e\u8eab\u624b<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5339\u914d\u89c4\u5219\u8fd8\u80fd\u7ec4\u5408\u3002\u4e00\u4e2a Stub \u53ef\u4ee5\u540c\u65f6\u8981\u6c42 method\u3001header\u3001body \u4e09\u5904\u90fd\u6ee1\u8db3\u624d\u547d\u4e2d\u3002\u5339\u914d\u8d8a\u7cbe\u786e\uff0cStub \u4e4b\u95f4\u8d8a\u4e0d\u5bb9\u6613\u6253\u67b6\u3002\u6211\u7684\u5efa\u8bae\u662f\uff1a\u5199 Mock \u65f6\u4e5f\u50cf\u5199\u7528\u4f8b\u4e00\u6837\u4e25\u8c28\uff0c\u628a\u8bf7\u6c42\u7ea6\u675f\u5199\u5168\uff0c\u540e\u9762\u6392\u67e5\u7701\u5fc3\u3002\u53cd\u8fc7\u6765\uff0c\u5982\u679c\u67d0\u4e2a Stub \u6c38\u8fdc\u4e0d\u88ab\u547d\u4e2d\uff0c\u591a\u534a\u662f\u7ea6\u675f\u5199\u5f97\u592a\u6b7b\uff0c\u6216\u8005\u8ddf\u53e6\u4e00\u4e2a\u66f4\u9ad8\u4f18\u5148\u7ea7\u7684 Stub \u62a2\u4e86\u5339\u914d<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">3.3 \u7528 Python \u9a8c\u8bc1<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5149\u5199 Stub \u4e0d\u591f\uff0c\u5f97\u9a8c\u8bc1\u5b83\u771f\u80fd\u7528\u3002\u6211\u7528 Pytest + Requests \u5199\u4e2a\u8f7b\u91cf\u9a8c\u8bc1\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"python\"><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;requests<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;pytest<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__comment\"># \u57fa\u7840\u5730\u5740\uff1a\u6307\u5411\u672c\u5730 WireMock \u5bb9\u5668<\/span><\/span><\/code><code><span leaf=\"\">BASE_URL =&nbsp;<span class=\"code-snippet__string\">\"http:\/\/localhost:8080\"<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_login_success<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u9a8c\u8bc1\u767b\u5f55\u63a5\u53e3\u80fd\u6b63\u5e38\u8fd4\u56de token\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; payload = {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"username\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"tester\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"password\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"123456\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; }<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u8c03\u7528 Mock \u51fa\u6765\u7684\u767b\u5f55\u63a5\u53e3<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; resp = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/login\"<\/span>, json=payload, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u65ad\u8a00\u72b6\u6001\u7801<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;resp.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; body = resp.json()<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u65ad\u8a00\u4e1a\u52a1\u5b57\u6bb5\u5b58\u5728\u4e14\u7c7b\u578b\u6b63\u786e<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;body[<span class=\"code-snippet__string\">\"code\"<\/span>] ==&nbsp;<span class=\"code-snippet__number\">0<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;<span class=\"code-snippet__string\">\"token\"<\/span>&nbsp;<span class=\"code-snippet__keyword\">in<\/span>&nbsp;body[<span class=\"code-snippet__string\">\"data\"<\/span>]<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;<span class=\"code-snippet__built_in\">isinstance<\/span>(body[<span class=\"code-snippet__string\">\"data\"<\/span>][<span class=\"code-snippet__string\">\"token\"<\/span>],&nbsp;<span class=\"code-snippet__built_in\">str<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;<span class=\"code-snippet__built_in\">len<\/span>(body[<span class=\"code-snippet__string\">\"data\"<\/span>][<span class=\"code-snippet__string\">\"token\"<\/span>]) &gt;&nbsp;<span class=\"code-snippet__number\">0<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_login_response_time<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u9a8c\u8bc1\u63a5\u53e3\u54cd\u5e94\u5728\u5408\u7406\u65f6\u95f4\u5185\u8fd4\u56de\uff08\u65e0\u5ef6\u8fdf\u914d\u7f6e\u65f6\uff09\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; resp = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/login\"<\/span>, json={}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;resp.elapsed.total_seconds() &lt;&nbsp;<span class=\"code-snippet__number\">1.0<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">pytest_login.py\uff0c\u7528 Pytest \u9a8c\u8bc1 Mock \u767b\u5f55\u63a5\u53e3\u53ef\u7528<\/span><\/span><\/span><\/section>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u8dd1\u8d77\u6765\uff0c\u7eff\u4e86\uff0c\u8bf4\u660e Mock \u63a5\u53e3\u5df2\u5c31\u7eea\u3002\u4ece\u8fd9\u4e00\u523b\u8d77\uff0c\u4f60\u7684\u767b\u5f55\u76f8\u5173\u6d4b\u8bd5\u7528\u4f8b\uff0c\u4e0d\u518d\u4f9d\u8d56\u540e\u7aef\u90a3\u6839\u8fd8\u6ca1\u5199\u597d\u7684\u63a5\u53e3<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9\u91cc\u6709\u4e2a\u5c0f\u6280\u5de7\uff1a\u628a BASE_URL \u62bd\u5230\u914d\u7f6e\u6587\u4ef6\u6216\u73af\u5883\u53d8\u91cf\uff0c\u522b\u786c\u7f16\u7801\u5728\u7528\u4f8b\u91cc\u3002\u8fd9\u6837\u540c\u4e00\u6761\u7528\u4f8b\uff0c\u6d4b\u8bd5\u73af\u5883\u6307\u5411 WireMock\uff0c\u8054\u8c03\u73af\u5883\u6307\u5411\u771f\u5b9e\u670d\u52a1\uff0c\u4e00\u884c\u4e0d\u6539\u5c31\u80fd\u5207\u6362\u3002\u540e\u9762\u7b2c\u4e03\u7ae0\u57512 \u4f1a\u518d\u5f3a\u8c03\u8fd9\u4ef6\u4e8b\uff0c\u56e0\u4e3a\u5b83\u786e\u5b9e\u5bb9\u6613\u5fd8\u3002\u53e6\u5916\uff0c\u65ad\u8a00\u522b\u53ea\u5199 status_code == 200\uff0c\u591a\u65ad\u8a00\u51e0\u4e2a\u4e1a\u52a1\u5b57\u6bb5\uff0cMock \u7684\u5951\u7ea6\u4ef7\u503c\u624d\u771f\u6b63\u53d1\u6325\u51fa\u6765<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u987a\u4fbf\u63d0\u4e00\u53e5\u65ad\u8a00\u7684\u7c92\u5ea6\u3002Mock \u51fa\u6765\u7684\u63a5\u53e3\uff0c\u65ad\u8a00\u8981\u6070\u5230\u597d\u5904\uff1a\u592a\u7c97\uff08\u53ea\u5224\u65ad 200\uff09\u6d4b\u4e0d\u51fa\u5951\u7ea6\u95ee\u9898\uff0c\u592a\u7ec6\uff08\u8fde token \u5b57\u7b26\u4e32\u90fd\u5199\u6b7b\u6bd4\u5bf9\uff09\u53c8\u4f1a\u8ba9\u7528\u4f8b\u8106\u5f31\u3001\u4e00\u6539\u5c31\u7ea2\u3002\u6211\u7684\u4e60\u60ef\u662f\u65ad\u8a00\u72b6\u6001\u7801\u3001\u5173\u952e\u4e1a\u52a1\u5b57\u6bb5\u7684\u5b58\u5728\u6027\u4e0e\u7c7b\u578b\uff0c\u4e0d\u7ea0\u7ed3\u5177\u4f53\u968f\u673a\u503c\u3002\u8fd9\u6837 Mock \u65e2\u80fd\u5e2e\u4f60\u5b88\u4f4f\u5951\u7ea6\uff0c\u53c8\u4e0d\u4f1a\u56e0\u4e3a\u65e0\u5173\u7ec6\u8282\u9891\u7e41\u5931\u8d25<\/span><\/p>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">04<\/span><\/span><span leaf=\"\">\u8fdb\u9636\u2014\u2014\u52a8\u6001\u54cd\u5e94\u4e0e\u72b6\u6001\u7ba1\u7406<\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">4.1 Response Templating<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4e0a\u9762\u90a3\u4e2a\u767b\u5f55\u63a5\u53e3\uff0c\u65e0\u8bba\u8c01\u767b\u5f55\u90fd\u8fd4\u56de\u540c\u4e00\u4e2a token\u3002\u771f\u5b9e\u573a\u666f\u91cc\uff0c\u6211\u4eec\u5e38\u9700\u8981\u6839\u636e\u8bf7\u6c42\u5185\u5bb9\u52a8\u6001\u751f\u6210\u54cd\u5e94\u3002\u8fd9\u5c31\u7528\u5230&nbsp;<\/span><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: #7b0c00;\">Response Templating<\/span><\/span><\/strong><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">WireMock \u5185\u7f6e Handlebars \u6a21\u677f\u5f15\u64ce\u3002\u4f60\u5728\u54cd\u5e94\u91cc\u5199 {{&#8230;}} \u5360\u4f4d\u7b26\uff0c\u5b83\u4f1a\u5728\u8fd4\u56de\u65f6\u66ff\u6362\u6210\u5b9e\u9645\u503c\u3002\u6bd4\u5982\u6839\u636e username \u4e0d\u540c\uff0c\u8fd4\u56de\u4e0d\u540c\u7684 code\uff1b\u7528 {{randomValue}} \u751f\u6210\u968f\u673a token<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"json\"><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"priority\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">1<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\">\/\/ \u4f18\u5148\u7ea7\uff0c\u6570\u5b57\u8d8a\u5c0f\u8d8a\u5148\u5339\u914d<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"request\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"method\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"POST\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"urlPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\/api\/login\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"response\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"status\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">200<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"headers\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"Content-Type\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"application\/json\"<\/span>&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"jsonBody\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"code\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"{{#eq request.body.username 'admin'}}0{{else}}1{{\/eq}}\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"msg\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"{{#eq request.body.username 'admin'}}success{{else}}invalid user{{\/eq}}\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"data\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"token\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"{{randomValue length=20 type='ALPHANUMERIC'}}\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"transformers\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">[<\/span><span class=\"code-snippet__string\">\"response-template\"<\/span><span class=\"code-snippet__punctuation\">]<\/span>&nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u5f00\u542f Handlebars \u6a21\u677f\u5f15\u64ce<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">dynamic_response.json\uff0c\u7528 Handlebars \u6a21\u677f\u6309\u8bf7\u6c42\u52a8\u6001\u751f\u6210\u54cd\u5e94<\/span><\/span><\/span><\/section>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u6ce8\u610f\u672b\u5c3e\u7684&nbsp;<\/span><code><span leaf=\"\">transformers: [\"response-template\"]<\/span><\/code><span leaf=\"\">\uff0c\u8fd9\u662f\u5f00\u542f\u6a21\u677f\u5f15\u64ce\u7684\u5f00\u5173\u3002\u6ca1\u6709\u5b83\uff0c{{&#8230;}} \u4f1a\u88ab\u5f53\u6210\u666e\u901a\u5b57\u7b26\u4e32\u539f\u6837\u8fd4\u56de\uff0c\u4f60\u5c31\u770b\u4e0d\u5230\u52a8\u6001\u6548\u679c\u4e86<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">Handlebars \u7684\u80fd\u529b\u4e0d\u6b62\u968f\u673a\u503c\u3002\u5b83\u80fd\u53d6\u8bf7\u6c42\u91cc\u7684 header\u3001query\u3001body \u5b57\u6bb5\uff0c\u80fd\u505a\u6761\u4ef6\u5224\u65ad\u3001\u5faa\u73af\u3001\u5b57\u7b26\u4e32\u5904\u7406\u3002\u6bd4\u5982\u6309\u8bf7\u6c42\u7684\u57ce\u5e02\u5b57\u6bb5\uff0c\u4ece\u4e00\u4efd\u5927 JSON \u91cc\u7b5b\u51fa\u5bf9\u5e94\u57ce\u5e02\u7684\u5929\u6c14\u8fd4\u56de\u3002\u914d\u5408 __files \u76ee\u5f55\u91cc\u7684\u6a21\u677f\u6587\u4ef6\uff0c\u4f60\u751a\u81f3\u80fd\u8fd4\u56de\u4e00\u6574\u9875\u6e32\u67d3\u597d\u7684 HTML\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u53ea\u8981\u4f60\u7684\u54cd\u5e94\u903b\u8f91\u80fd\u7528\u6a21\u677f\u8868\u8fbe\uff0cWireMock \u90fd\u80fd\u66ff\u4f60\u6f14\u51fa\u6765\uff0c\u800c\u4e0d\u5fc5\u5199\u4e00\u884c\u670d\u52a1\u7aef\u4ee3\u7801<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u63d0\u9192\u4e00\u4e2a\u987a\u5e8f\u95ee\u9898\uff1a\u5982\u679c\u4f60\u540c\u65f6\u5f00\u4e86 response-template \u548c\u522b\u7684 transformer\uff0ctransformers \u6570\u7ec4\u91cc\u7684\u987a\u5e8f\u4f1a\u5f71\u54cd\u6267\u884c\u5148\u540e\u3002\u5927\u591a\u6570\u573a\u666f\u4e0b\u4f60\u53ea\u9700\u8981 response-template\uff0c\u4e0d\u5fc5\u53e0\u52a0<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">4.2 \u573a\u666f\uff1a\u767b\u5f55\u6210\u529f \/ \u5931\u8d25 \/ \u8fc7\u671f<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u540c\u4e00\u63a5\u53e3\u6309\u6761\u4ef6\u8fd4\u56de\u4e0d\u540c\u7ed3\u679c\uff0c\u5e38\u89c1\u4e8e&#8221;\u767b\u5f55\u6001&#8221;\u6d4b\u8bd5\u3002\u6bd4\u5982\uff1ausername \u662f admin\uff0c\u8fd4\u56de\u6210\u529f\uff1b\u662f locked\uff0c\u8fd4\u56de\u8d26\u53f7\u9501\u5b9a\uff1b\u662f expire\uff0c\u8fd4\u56de token \u8fc7\u671f\u3002\u7528 Handlebars \u7684 eq \u5224\u65ad\u5c31\u80fd\u5b9e\u73b0\u5206\u652f<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9\u79cd&#8221;\u6309\u8f93\u5165\u8fd4\u56de\u4e0d\u540c\u8f93\u51fa&#8221;\u7684\u80fd\u529b\uff0c\u8ba9\u4f60\u4e00\u4e2a Stub \u8986\u76d6\u591a\u79cd\u7528\u4f8b\uff0c\u4e0d\u7528\u4e3a\u6bcf\u4e2a\u5206\u652f\u5355\u72ec\u5efa\u6587\u4ef6\u3002\u7ef4\u62a4\u6210\u672c\u4e00\u4e0b\u5b50\u964d\u4e0b\u6765<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4e0d\u8fc7\u8981\u514b\u5236\u3002\u52a8\u6001\u6a21\u677f\u5199\u5f97\u592a\u82b1\uff0cMock \u672c\u8eab\u5c31\u6210\u4e86\u9700\u8981\u7ef4\u62a4\u7684\u903b\u8f91\u3002\u6211\u7684\u539f\u5219\u662f\uff1a\u52a8\u6001\u90e8\u5206\u53ea\u670d\u52a1\u4e8e&#8221;\u8ba9\u6d4b\u8bd5\u66f4\u771f\u5b9e&#8221;\uff0c\u4e0d\u4e3a\u70ab\u6280\u3002\u80fd\u7528\u56fa\u5b9a\u503c\u8868\u8fbe\u7684\uff0c\u5c31\u522b\u4e0a\u6a21\u677f\u3002<span textstyle=\"\" style=\"color: #ff2941;text-decoration: underline;\">\u6bd5\u7adf Mock \u662f\u624b\u6bb5\u4e0d\u662f\u76ee\u7684\uff0c\u5b83\u8be5\u5e2e\u4f60\u65e9\u70b9\u6d4b\u5b8c\uff0c\u800c\u4e0d\u662f\u53d8\u6210\u53e6\u4e00\u4e2a\u8981\u6d4b\u7684\u7cfb\u7edf<\/span><\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">4.3 \u72b6\u6001\u673a\uff1a\u591a\u6b65\u9aa4\u6d41\u7a0b<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u66f4\u590d\u6742\u7684\u573a\u666f\u662f&#8221;\u6709\u5148\u540e\u987a\u5e8f&#8221;\u7684\u63a5\u53e3\u3002\u6bd4\u5982\u7535\u5546\u4e0b\u5355\uff1a\u6ca1\u52a0\u8d2d\u5c31\u53bb\u4e0b\u5355\uff0c\u5e94\u8be5\u62a5\u9519\uff1b\u52a0\u8d2d\u4e4b\u540e\u624d\u80fd\u4e0b\u5355\uff1b\u4e0b\u5355\u4e4b\u540e\u624d\u80fd\u652f\u4ed8<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9\u79cd\u6b65\u9aa4\u4f9d\u8d56\uff0c\u9760&nbsp;<\/span><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: #7b0c00;\">Scenarios\uff08\u72b6\u6001\u673a\uff09<\/span><\/span><\/strong><span leaf=\"\">&nbsp;\u5b9e\u73b0\u3002\u6bcf\u4e2a Stub \u58f0\u660e\u81ea\u5df1\u5c5e\u4e8e\u54ea\u4e2a\u573a\u666f\u3001\u5f53\u524d\u9700\u8981\u4ec0\u4e48\u72b6\u6001\u3001\u547d\u4e2d\u540e\u5207\u6362\u5230\u4ec0\u4e48\u72b6\u6001\u3002WireMock \u4f1a\u6309\u8c03\u7528\u987a\u5e8f\u7ef4\u62a4\u72b6\u6001<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"json\"><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"scenarioName\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"ShoppingFlow\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\">\/\/ \u72b6\u6001\u673a\u540d\u79f0\uff0c\u591a\u4e2a Stub \u5171\u4eab<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"requiredScenarioState\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"Started\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;&nbsp;<span class=\"code-snippet__comment\">\/\/ \u5f53\u524d\u72b6\u6001\u4e0b\u624d\u5339\u914d<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"newScenarioState\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"CartAdded\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u5339\u914d\u540e\u8fc1\u79fb\u5230\u65b0\u72b6\u6001<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"request\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"method\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"POST\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"urlPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\/api\/cart\/add\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"response\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"status\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">200<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"jsonBody\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"code\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">0<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"msg\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"added to cart\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"data\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"cartId\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"C1001\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;<span class=\"code-snippet__attr\">\"count\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">1<\/span>&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">scenario_cart.json\uff0c\u7528\u72b6\u6001\u673a\u7ea6\u675f&#8221;\u5148\u52a0\u8d2d\u518d\u4e0b\u5355&#8221;\u7684\u8c03\u7528\u987a\u5e8f<\/span><\/span><\/span><\/section>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u4e0a\u9762\u8fd9\u4e2a Stub \u5c5e\u4e8e ShoppingFlow \u573a\u666f\uff0c\u8981\u6c42\u5f53\u524d\u72b6\u6001\u662f Started\uff0c\u547d\u4e2d\u540e\u628a\u72b6\u6001\u5207\u5230 CartAdded\u3002\u540e\u7eed\u7684&#8221;\u4e0b\u5355&#8221;Stub \u5c31\u53ef\u4ee5\u8981\u6c42\u72b6\u6001\u5fc5\u987b\u662f CartAdded \u624d\u5339\u914d\u2014\u2014\u6ca1\u52a0\u8d2d\u76f4\u63a5\u4e0b\u5355\uff0c\u81ea\u7136\u5339\u914d\u4e0d\u5230\uff0c\u8fd4\u56de\u4f60\u9884\u8bbe\u7684\u5931\u8d25\u54cd\u5e94<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u72b6\u6001\u673a\u7684\u9ed8\u8ba4\u503c\u53eb Started\uff0c\u6240\u6709 Stub \u521d\u59cb\u90fd\u5904\u5728 Started\u3002\u4f60\u53ef\u4ee5\u5b9a\u4e49\u4efb\u610f\u591a\u4e2a\u72b6\u6001\u540d\uff0c\u4e32\u6210\u4efb\u610f\u957f\u7684\u6d41\u7a0b\u3002\u4f46\u8981\u6ce8\u610f\uff1a\u72b6\u6001\u662f WireMock \u5b9e\u4f8b\u7ea7\u522b\u7684\u5168\u5c40\u72b6\u6001\uff0c\u591a\u4e2a\u7528\u4f8b\u5e76\u884c\u8dd1\u65f6\u53ef\u80fd\u4e92\u76f8\u5e72\u6270<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">4.4 \u7528 Pytest \u8dd1\u7aef\u5230\u7aef\u6d41\u7a0b<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u628a\u72b6\u6001\u673a\u4e32\u8d77\u6765\uff0c\u5c31\u662f\u4e00\u6761\u7aef\u5230\u7aef\u94fe\u8def\u3002\u6211\u7528 Pytest \u5199\u4e00\u4e2a\u5b8c\u6574\u6d41\u7a0b\u9a8c\u8bc1\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"python\"><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;requests<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;pytest<\/span><\/code><code><span leaf=\"\">BASE_URL =&nbsp;<span class=\"code-snippet__string\">\"http:\/\/localhost:8080\"<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__comment\"># \u91cd\u7f6e\u72b6\u6001\u673a\u63a5\u53e3\uff0c\u4fdd\u8bc1\u6bcf\u6b21\u7528\u4f8b\u4ece Started \u5f00\u59cb<\/span><\/span><\/code><code><span leaf=\"\">SCENARIO_RESET =&nbsp;<span class=\"code-snippet__string\">\"http:\/\/localhost:8080\/__admin\/scenarios\/reset\"<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_state_transition<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u9a8c\u8bc1\u72b6\u6001\u673a\uff1a\u672a\u52a0\u8d2d\u76f4\u63a5\u4e0b\u5355\u5e94\u5931\u8d25\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; requests.post(SCENARIO_RESET) &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u5148\u91cd\u7f6e\uff0c\u907f\u514d\u4e0a\u6b21\u7528\u4f8b\u6b8b\u7559\u72b6\u6001<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u672a\u52a0\u8d2d\uff0c\u76f4\u63a5\u8c03\u4e0b\u5355\u63a5\u53e3\uff0c\u671f\u671b\u5339\u914d\u4e0d\u5230\uff08\u8fd4\u56de 404\uff09<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/order\/create\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; json={<span class=\"code-snippet__string\">\"cartId\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"C1001\"<\/span>}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r.status_code ==&nbsp;<span class=\"code-snippet__number\">404<\/span>&nbsp; &nbsp;<span class=\"code-snippet__comment\"># \u72b6\u6001\u4e0d\u5bf9\uff0cStub \u672a\u547d\u4e2d<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u5148\u52a0\u8d2d\uff0c\u72b6\u6001\u5207\u5230 CartAdded<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r2 = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/cart\/add\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"productId\"<\/span>:&nbsp;<span class=\"code-snippet__number\">1<\/span>,&nbsp;<span class=\"code-snippet__string\">\"count\"<\/span>:&nbsp;<span class=\"code-snippet__number\">1<\/span>}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r2.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u518d\u52a0\u8d2d\u540e\u4e0b\u5355\uff0c\u671f\u671b\u6210\u529f<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r3 = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/order\/create\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"cartId\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"C1001\"<\/span>}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r3.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">pytest_state.py\uff0c\u9a8c\u8bc1\u72b6\u6001\u673a\u7ea6\u675f\u4e0b&#8221;\u5148\u52a0\u8d2d\u518d\u4e0b\u5355&#8221;\u7684\u8c03\u7528\u987a\u5e8f<\/span><\/span><\/span><\/section>\n<section><span style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u5173\u952e\u70b9\uff1a<\/span>\u6bcf\u6b21\u8dd1\u4e4b\u524d\u5148 POST \/__admin\/scenarios\/reset \u91cd\u7f6e\u72b6\u6001\u673a\uff0c\u5426\u5219\u4e0a\u4e00\u6b21\u8dd1\u7559\u4e0b\u7684\u72b6\u6001\u4f1a\u6c61\u67d3\u4e0b\u4e00\u6b21\u3002\u628a&#8221;\u672a\u52a0\u8d2d\u4e0b\u5355&#8221;\u548c&#8221;\u52a0\u8d2d\u540e\u4e0b\u5355&#8221;\u4e24\u79cd\u5206\u652f\u90fd\u8986\u76d6\uff0c\u72b6\u6001\u673a\u7684\u4ef7\u503c\u5c31\u4f53\u73b0\u51fa\u6765\u4e86<\/span><\/span><\/section>\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"576\">\n<p data-pm-slice=\"0 0 []\" style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 16px;font-weight: bold;\">\u270d \u7ecf\u9a8c\uff1aCI \u4e0a\u5076\u53d1\u5931\u8d25\u539f\u6765\u662f\u72b6\u6001\u673a\u6363\u7684\u9b3c<\/span><\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6709\u6bb5\u65f6\u95f4\uff0cCI \u4e0a\u7684\u7528\u4f8b\u5076\u53d1\u5931\u8d25\uff0c\u672c\u5730\u590d\u73b0\u4e0d\u4e86\u3002\u67e5\u4e86\u4e09\u56db\u5929\uff0c\u6700\u540e\u53d1\u73b0\u662f\u524d\u4e00\u5929\u665a\u4e0a\u6709\u4eba\u624b\u52a8\u8c03\u4e86\u4e00\u6b21\u652f\u4ed8\u63a5\u53e3\uff0c\u628a\u72b6\u6001\u505c\u5728\u4e86 Paid\u3002\u7b2c\u4e8c\u5929\u9996\u6279\u7528\u4f8b\u4ece\u9519\u8bef\u7684\u72b6\u6001\u5f00\u59cb\uff0c\u540e\u7eed\u7684\u72b6\u6001\u6d41\u8f6c\u5168\u90e8\u9519\u4f4d\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u89e3\u51b3\u65b9\u6cd5\u662f\uff1a\u5728\u6bcf\u4e2a\u7528\u4f8b\u5f00\u5934\u52a0 reset\uff0c\u800c\u4e0d\u662f\u7ed3\u5c3e\u2014\u2014\u7ed3\u5c3e reset \u89e3\u51b3\u4e0d\u4e86\u4e0b\u4e00\u4e2a\u7528\u4f8b\u5f00\u5934\u7684\u95ee\u9898\u3002\u4e4b\u540e\u4e16\u754c\u6e05\u51c0\u4e86\u3002\u6240\u4ee5\u8bb0\u4f4f\uff1a\u51e1\u7528\u72b6\u6001\u673a\u7684\u81ea\u52a8\u5316\uff0creset \u4e0d\u662f\u53ef\u9009\u9879\uff0c\u662f\u5fc5\u9009\u9879\u3002<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">05<\/span><\/span><span leaf=\"\">\u5b9e\u6218\u2014\u2014Mock\u4e00\u4e2a\u5b8c\u6574\u7535\u5546\u4e0b\u5355\u6d41\u7a0b<\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">5.1 \u63a5\u53e3\u6e05\u5355<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6211\u4eec\u6311\u4e00\u6761\u5b8c\u6574\u7684\u7535\u5546\u4e0b\u5355\u94fe\u8def\uff0c\u4e00\u5171 5 \u4e2a\u63a5\u53e3\uff1a<\/span><\/p>\n<ul style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" class=\"list-paddingleft-1\">\n<li>\n<section><span leaf=\"\">\u5546\u54c1\u5217\u8868\uff1a<span textstyle=\"\" style=\"color: #0052ff;font-weight: bold;\">GET<\/span><span textstyle=\"\" style=\"color: #0052ff;\">&nbsp;\/api\/products<\/span><\/span><\/section>\n<\/li>\n<li>\n<section><span leaf=\"\">\u5546\u54c1\u8be6\u60c5\uff1a<span textstyle=\"\" style=\"color: #0052ff;font-weight: bold;\">GET<\/span><span textstyle=\"\" style=\"color: #0052ff;\">&nbsp;\/api\/products\/{id}<\/span><\/span><\/section>\n<\/li>\n<li>\n<section><span leaf=\"\">\u52a0\u5165\u8d2d\u7269\u8f66\uff1a<span textstyle=\"\" style=\"color: #0052ff;font-weight: bold;\">POST<\/span><span textstyle=\"\" style=\"color: #0052ff;\">&nbsp;\/api\/cart\/add<\/span><\/span><\/section>\n<\/li>\n<li>\n<section><span leaf=\"\">\u4e0b\u5355\uff1a<span textstyle=\"\" style=\"color: #0052ff;font-weight: bold;\">POST<\/span><span textstyle=\"\" style=\"color: #0052ff;\">&nbsp;\/api\/order\/create<\/span><\/span><\/section>\n<\/li>\n<li>\n<section><span leaf=\"\">\u652f\u4ed8\uff1a<span textstyle=\"\" style=\"color: #0052ff;font-weight: bold;\">POST&nbsp;<\/span><span textstyle=\"\" style=\"color: #0052ff;\">\/api\/pay<\/span><\/span><\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9 5 \u4e2a\u63a5\u53e3\u4e32\u8d77\u6765\uff0c\u8986\u76d6\u4e86&#8221;\u770b\u2014\u9009\u2014\u52a0\u2014\u4e70\u2014\u4ed8&#8221;\u7684\u5b8c\u6574\u7528\u6237\u8def\u5f84\u3002\u540e\u7aef\u6ca1\u5199\uff1f\u6211\u4eec\u7528 WireMock \u628a\u6574\u6761\u94fe Mock \u51fa\u6765\uff0c\u6d4b\u8bd5\u7167\u6837\u80fd\u8dd1<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6311\u8fd9\u6761\u94fe\u662f\u6709\u7528\u610f\u7684\uff1a\u5b83\u65e2\u6709\u8bfb\uff08\u5217\u8868\u3001\u8be6\u60c5\uff09\uff0c\u53c8\u6709\u5199\uff08\u52a0\u8d2d\u3001\u4e0b\u5355\u3001\u652f\u4ed8\uff09\uff0c\u8fd8\u8de8\u4e86\u591a\u4e2a\u72b6\u6001\u3002\u4e00\u6761\u7528\u4f8b\u5c31\u80fd\u8986\u76d6&#8221;\u8bfb-\u5199-\u72b6\u6001&#8221;\u4e09\u7c7b\u884c\u4e3a\u3002\u4f60\u62ff\u81ea\u5df1\u9879\u76ee\u7684\u4efb\u610f\u6838\u5fc3\u94fe\u8def\u5957\u8fd9\u5957\u65b9\u6cd5\u90fd\u884c\uff0c\u4e0d\u5fc5\u662f\u7535\u5546\u3002\u8ba2\u5355\u6d41\u8f6c\u3001\u5ba1\u6279\u6d41\u3001\u6ce8\u518c\u767b\u5f55\u6d41\uff0c\u672c\u8d28\u90fd\u4e00\u6837\u2014\u2014\u628a\u5b83\u4eec\u62c6\u6210&#8221;\u63a5\u53e3\u8282\u70b9 + \u72b6\u6001\u6d41\u8f6c&#8221;\uff0cWireMock \u5c31\u80fd\u5b8c\u6574\u6f14\u4e00\u904d<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #0052ff;\">\u8fd8\u6709\u4e00\u70b9\u5f88\u5b9e\u7528\uff1a\u8fd9\u6761\u94fe\u8def\u9020\u51fa\u6765\u4e4b\u540e\uff0c\u4f60\u4e0d\u6b62\u80fd\u6d4b\u529f\u80fd\uff0c\u8fd8\u80fd\u62ff\u5b83\u505a\u6f14\u793a\u548c\u538b\u6d4b\u57fa\u7ebf\u3002\u6bd4\u5982\u7ed9\u524d\u7aef\u540c\u5b66\u4e00\u4e2a\u7a33\u5b9a\u7684&#8221;\u5047\u540e\u7aef&#8221;\uff0c\u4ed6\u4e0d\u5fc5\u7b49\u4efb\u4f55\u4eba\u5c31\u80fd\u8c03\u9875\u9762\uff1b\u7ed9\u6027\u80fd\u540c\u5b66\u4e00\u4e2a\u53ef\u63a7\u7684\u4e0b\u6e38\uff0c\u6392\u9664\u5916\u90e8\u53d8\u91cf\u3002\u4e00\u4e2a Mock \u94fe\u8def\uff0c\u5e38\u5e38\u80fd\u540c\u65f6\u670d\u52a1\u6d4b\u8bd5\u3001\u524d\u7aef\u3001\u6027\u80fd\u4e09\u65b9\uff0c\u6295\u5165\u4ea7\u51fa\u6bd4\u5f88\u9ad8<\/span><\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">5.2 Mock \u6620\u5c04\u6587\u4ef6<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">5 \u4e2a JSON \u6620\u5c04\u6587\u4ef6\uff0c\u5206\u522b\u653e\u5728 mappings \u4e0b\u3002\u5546\u54c1\u5217\u8868\u7528\u6a21\u677f\u968f\u673a\u751f\u6210\u5546\u54c1\uff1b\u52a0\u8d2d\u89e6\u53d1\u72b6\u6001\u8fc1\u79fb\uff1b\u4e0b\u5355\u8981\u6c42 CartAdded \u72b6\u6001\uff1b\u652f\u4ed8\u8981\u6c42 Ordered \u72b6\u6001\uff1b\u652f\u4ed8\u6210\u529f\u540e\u5207\u5230 Paid<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4e0b\u9762\u628a&#8221;\u5546\u54c1\u5217\u8868&#8221;\u548c&#8221;\u652f\u4ed8&#8221;\u4e24\u4e2a\u8d34\u51fa\u6765\uff0c\u5176\u4f59\u7ed3\u6784\u7c7b\u4f3c\uff0c\u6309\u9700\u7ec4\u5408\u72b6\u6001\u673a\u5373\u53ef\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"css\"><code><span leaf=\"\">{<\/span><\/code><code><span leaf=\"\">&nbsp; \"request\": { \"method\":&nbsp;<span class=\"code-snippet__string\">\"GET\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"urlPath\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"\/api\/products\"<\/span>&nbsp;},<\/span><\/code><code><span leaf=\"\">&nbsp; \"response\": {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; \"status\":&nbsp;<span class=\"code-snippet__number\">200<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"jsonBody\"<\/span>: {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; \"<span class=\"code-snippet__selector-tag\">code<\/span>\":&nbsp;<span class=\"code-snippet__number\">0<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"data\"<\/span>: [<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; { \"id\":&nbsp;<span class=\"code-snippet__number\">1<\/span>,&nbsp;<span class=\"code-snippet__string\">\"name\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"{{randomValue type='ALPHANUMERIC' length=6}}\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"price\"<\/span>:&nbsp;<span class=\"code-snippet__number\">99<\/span>&nbsp;},<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; { \"id\":&nbsp;<span class=\"code-snippet__number\">2<\/span>,&nbsp;<span class=\"code-snippet__string\">\"name\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"{{randomValue type='ALPHANUMERIC' length=6}}\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"price\"<\/span>:&nbsp;<span class=\"code-snippet__number\">199<\/span>&nbsp;}<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; ]<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; },<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; \"transformers\": [<span class=\"code-snippet__string\">\"response-template\"<\/span>]<\/span><\/code><code><span leaf=\"\">&nbsp; }<\/span><\/code><code><span leaf=\"\">}<\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">products.json\uff0c\u5546\u54c1\u5217\u8868\u63a5\u53e3\uff08\u6a21\u677f\u52a8\u6001\u751f\u6210\u5546\u54c1\u540d\uff09<\/span><\/span><\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"json\"><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"scenarioName\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"ShoppingFlow\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"requiredScenarioState\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"Ordered\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\">\/\/ \u5fc5\u987b\u5df2\u4e0b\u5355<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"newScenarioState\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"Paid\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u652f\u4ed8\u540e\u5207\u5230 Paid<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"request\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"method\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"POST\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;<span class=\"code-snippet__attr\">\"urlPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\/api\/pay\"<\/span>&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"response\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"status\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">200<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"jsonBody\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"code\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">0<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;<span class=\"code-snippet__attr\">\"data\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"paid\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__literal\"><span class=\"code-snippet__keyword\">true<\/span><\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;<span class=\"code-snippet__attr\">\"orderId\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"{{request.body.orderId}}\"<\/span>&nbsp;<span class=\"code-snippet__punctuation\">}<\/span>&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"transformers\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">[<\/span><span class=\"code-snippet__string\">\"response-template\"<\/span><span class=\"code-snippet__punctuation\">]<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">pay.json\uff0c\u652f\u4ed8\u63a5\u53e3\uff08\u8981\u6c42 Ordered \u72b6\u6001\uff0c\u5e76\u628a\u8bf7\u6c42\u91cc\u7684 orderId \u56de\u5199\u54cd\u5e94\uff09<\/span><\/span><\/span><\/section>\n<section style=\"text-indent: 2em;\"><span style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u5b9e\u9645\u843d\u5730\u65f6\uff0c\u6211\u4e60\u60ef\u628a 5 \u4e2a Stub \u62c6\u6210 5 \u4e2a\u72ec\u7acb JSON \u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u89c1\u540d\u77e5\u610f\uff1aproducts.json\u3001product_detail.json\u3001cart_add.json\u3001order_create.json\u3001pay.json\u3002\u8fd9\u6837\u8c01\u6539\u4e86\u54ea\u4e2a\u63a5\u53e3\u4e00\u76ee\u4e86\u7136\uff0c\u4e5f\u65b9\u4fbf\u6309\u63a5\u53e3\u7ef4\u5ea6\u505a\u7248\u672c\u7ba1\u7406\u3002\u5f53\u771f\u5b9e\u63a5\u53e3\u6587\u6863\u66f4\u65b0\u65f6\uff0c\u4f60\u53ea\u8981\u6539\u5bf9\u5e94\u90a3\u4e2a\u6587\u4ef6\uff0c\u4e0d\u4f1a\u7275\u4e00\u53d1\u52a8\u5168\u8eab<\/span><\/span><\/section>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">5.3 Pytest \u6d4b\u8bd5\u811a\u672c<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u628a 5 \u4e2a\u63a5\u53e3\u5168\u4e32\u8d77\u6765\uff0c\u5199\u6210\u4e00\u6761\u7aef\u5230\u7aef\u7528\u4f8b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"python\"><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;requests<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;pytest<\/span><\/code><code><span leaf=\"\">BASE_URL =&nbsp;<span class=\"code-snippet__string\">\"http:\/\/localhost:8080\"<\/span><\/span><\/code><code><span leaf=\"\">SCENARIO_RESET =&nbsp;<span class=\"code-snippet__string\">\"http:\/\/localhost:8080\/__admin\/scenarios\/reset\"<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_full_order_flow<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u7aef\u5230\u7aef\uff1a\u6d4f\u89c8 -&gt; \u52a0\u8d2d -&gt; \u4e0b\u5355 -&gt; \u652f\u4ed8\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6b65\u9aa40\uff1a\u91cd\u7f6e\u72b6\u6001\u673a\uff0c\u4fdd\u8bc1\u6bcf\u6b21\u4ece Started \u5f00\u59cb<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; requests.post(SCENARIO_RESET)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6b65\u9aa41\uff1a\u5546\u54c1\u5217\u8868<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r1 = requests.get(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/products\"<\/span>, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r1.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; product_id = r1.json()[<span class=\"code-snippet__string\">\"data\"<\/span>][<span class=\"code-snippet__number\">0<\/span>][<span class=\"code-snippet__string\">\"id\"<\/span>]<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6b65\u9aa42\uff1a\u5546\u54c1\u8be6\u60c5<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r2 = requests.get(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/products\/<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{product_id}<\/span><\/span><span class=\"code-snippet__string\">\"<\/span>, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r2.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6b65\u9aa43\uff1a\u52a0\u5165\u8d2d\u7269\u8f66\uff08\u89e6\u53d1\u72b6\u6001 CartAdded\uff09<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r3 = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/cart\/add\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"productId\"<\/span>: product_id,&nbsp;<span class=\"code-snippet__string\">\"count\"<\/span>:&nbsp;<span class=\"code-snippet__number\">1<\/span>}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r3.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; cart_id = r3.json()[<span class=\"code-snippet__string\">\"data\"<\/span>][<span class=\"code-snippet__string\">\"cartId\"<\/span>]<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6b65\u9aa44\uff1a\u4e0b\u5355\uff08\u9700\u8981 CartAdded \u72b6\u6001\uff09<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r4 = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/order\/create\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"cartId\"<\/span>: cart_id}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r4.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; order_id = r4.json()[<span class=\"code-snippet__string\">\"data\"<\/span>][<span class=\"code-snippet__string\">\"orderId\"<\/span>]<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u6b65\u9aa45\uff1a\u652f\u4ed8\uff08\u9700\u8981 Ordered \u72b6\u6001\uff09<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r5 = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/pay\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"orderId\"<\/span>: order_id,&nbsp;<span class=\"code-snippet__string\">\"amount\"<\/span>:&nbsp;<span class=\"code-snippet__number\">99.0<\/span>}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r5.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r5.json()[<span class=\"code-snippet__string\">\"data\"<\/span>][<span class=\"code-snippet__string\">\"paid\"<\/span>]&nbsp;<span class=\"code-snippet__keyword\">is<\/span>&nbsp;<span class=\"code-snippet__literal\">True<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">pytest_ecommerce.py\uff0c5 \u63a5\u53e3\u8054\u52a8\u7684\u7aef\u5230\u7aef\u6d4b\u8bd5\uff08\u6570\u636e\u5728\u6b65\u9aa4\u95f4\u4f20\u9012\uff09<\/span><\/span><\/span><\/section>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u8fd9\u4e2a\u811a\u672c\u628a 5 \u4e2a\u63a5\u53e3\u5168\u4e32\u8d77\u6765\u4e86\u3002\u6ce8\u610f\u4e09\u4ef6\u4e8b\uff1a\u72b6\u6001\u91cd\u7f6e\u3001\u6570\u636e\u4f20\u9012\u3001\u9010\u6b65\u65ad\u8a00\u3002\u4efb\u4f55\u4e00\u6b65\u65ad\u6389\uff0c\u6d4b\u8bd5\u7acb\u523b\u7ea2\uff0c\u4f60\u80fd\u7cbe\u51c6\u5b9a\u4f4d\u662f&#8221;\u63a5\u53e3\u5951\u7ea6&#8221;\u8fd8\u662f&#8221;\u8c03\u7528\u987a\u5e8f&#8221;\u51fa\u4e86\u95ee\u9898<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd9\u6761\u7aef\u5230\u7aef\u7528\u4f8b\u7684\u4ef7\u503c\uff0c\u4e0d\u53ea\u662f&#8221;\u8bc1\u660e\u63a5\u53e3\u901a&#8221;\u3002\u5b83\u50cf\u4e00\u4efd\u53ef\u6267\u884c\u7684\u63a5\u53e3\u6587\u6863\uff1a\u65b0\u540c\u5b66\u770b\u8fd9\u4e2a\u811a\u672c\uff0c\u5c31\u77e5\u9053\u6b63\u786e\u8c03\u7528\u987a\u5e8f\u662f\u4ec0\u4e48\u3001\u6bcf\u4e00\u6b65\u8981\u4f20\u4ec0\u4e48\u5b57\u6bb5\u3001\u5b57\u6bb5\u4ece\u54ea\u4e00\u6b65\u6765\u3002\u5951\u7ea6\u4e00\u65e6\u53d8\u4e86\uff0c\u811a\u672c\u5148\u7ea2\uff0c\u6bd4\u4eba\u8089 review \u6587\u6863\u9760\u8c31\u5f97\u591a\u3002\u6211\u751a\u81f3\u628a\u5b83\u5f53\u5165\u804c\u57f9\u8bad\u6750\u6599\u7528\u2014\u2014\u65b0\u4eba\u7167\u7740\u811a\u672c\u8dd1\u4e00\u904d\uff0c\u6bd4\u770b\u4e09\u9875\u63a5\u53e3\u6587\u6863\u5b66\u5f97\u90fd\u5feb<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">5.4 \u62a5\u544a\u751f\u6210<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u56e2\u961f\u7528\u7684\u8bdd\uff0c\u5149\u6709 print \u4e0d\u591f\u3002\u6211\u63a5\u5165 Allure\uff0c\u628a\u6bcf\u6b21\u8bf7\u6c42\u548c\u54cd\u5e94\u4f5c\u4e3a\u9644\u4ef6\u6302\u5230\u62a5\u544a\u4e0a\u3002\u8fd9\u6837\u7528\u4f8b\u5931\u8d25\u65f6\uff0c\u70b9\u5f00\u5c31\u80fd\u770b\u5230\u5f53\u65f6 Mock \u8fd4\u56de\u4e86\u4ec0\u4e48\uff0c\u6392\u67e5\u6548\u7387\u5f88\u9ad8<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u505a\u6cd5\u4e5f\u5f88\u8f7b\uff1a\u5728\u8bf7\u6c42\u524d\u540e\u7528 allure.attach \u628a request\/response \u5185\u5bb9\u4ee5 text \u5f62\u5f0f\u6302\u4e0a\u53bb\u3002WireMock \u672c\u8eab\u4e0d\u4f9d\u8d56 Allure\uff0c\u4e8c\u8005\u662f\u89e3\u8026\u7684\uff0c\u4f60\u60f3\u6362 pytest-html \u540c\u6837\u53ef\u884c<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u8865\u5145\u4e00\u53e5<\/span>\uff1aAllure \u7684\u9644\u4ef6\u4e0d\u53ea\u6302\u54cd\u5e94\uff0c\u4e5f\u53ef\u4ee5\u6302\u8bf7\u6c42\u3002\u51fa\u95ee\u9898\u65f6\uff0c\u8bf7\u6c42\u548c\u54cd\u5e94\u5bf9\u7167\u7740\u770b\uff0c\u5b9a\u4f4d\u66f4\u5feb\u3002\u62a5\u544a\u91cc\u6211\u901a\u5e38\u8fd8\u4f1a\u5728\u7528\u4f8b\u6536\u5c3e\u52a0\u4e00\u6b65&#8221;\u8c03\u5b8c reset&#8221;\uff0c\u4fdd\u8bc1\u6bcf\u4e2a\u7528\u4f8b\u72ec\u7acb\uff0c\u907f\u514d\u8fde\u9501\u6c61\u67d3\u3002\u5f53\u7528\u4f8b\u6570\u91cf\u4e0a\u53bb\u4e4b\u540e\uff0c\u8fd9\u79cd&#8221;\u5404\u81ea\u5e72\u51c0&#8221;\u7684\u7eaa\u5f8b\uff0c\u6bd4\u4efb\u4f55\u8c03\u8bd5\u6280\u5de7\u90fd\u91cd\u8981<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5f53\u94fe\u8def\u53d8\u957f\u3001\u7528\u4f8b\u53d8\u591a\uff0c\u6211\u8fd8\u4f1a\u628a&#8221;\u91cd\u7f6e\u72b6\u6001\u673a&#8221;\u62bd\u6210\u4e00\u4e2a pytest fixture\uff0c\u6bcf\u4e2a\u7528\u4f8b\u81ea\u52a8\u5957\u7528\uff0c\u4e0d\u7528\u6bcf\u6b21\u624b\u5199 reset\u3002\u914d\u5408 conftest.py \u7edf\u4e00 BASE_URL \u7684\u6765\u6e90\uff0c\u6574\u4e2a\u6d4b\u8bd5\u5de5\u7a0b\u7684\u5165\u53e3\u5c31\u6536\u655b\u5230\u4e00\u5904\uff0c\u65b0\u4eba\u63a5\u624b\u4e5f\u4e0d\u4f1a\u628a\u73af\u5883\u914d\u9519\u3002\u5de5\u7a0b\u5316\u8fd9\u4e00\u6b65\uff0c\u662f\u4ece&#8221;\u80fd\u8dd1&#8221;\u5230&#8221;\u597d\u7ef4\u62a4&#8221;\u7684\u5206\u6c34\u5cad<\/span><\/p>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000716\" data-ratio=\"0.40370370370370373\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/BWmfcibGhS1JDKu9IFpcpy6KvrKbSsgOnxuutTzYP5UbGO8I7hPh6th9jQXgUZCxXsjznW5mbiaqyZ25JwhibMx3iaUCBQrz8PyVkpURuAWhvJo\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">\u7535\u5546\u4e0b\u5355 Mock \u5b8c\u6574\u6d41\u7a0b\u2014\u20145 \u63a5\u53e3\u8282\u70b9\u6309\u72b6\u6001\u673a\u6d41\u8f6c\uff0c\u6570\u636e\u5728\u6b65\u9aa4\u95f4\u987a\u5e8f\u4f20\u9012<\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">06<\/span><\/span><span leaf=\"\">\u9ad8\u9636\u2014\u2014\u6545\u969c\u6a21\u62df\u4e0e\u5ef6\u8fdf\u6ce8\u5165<\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">6.1 \u5ef6\u8fdf\u54cd\u5e94<\/span><\/span><\/h3>\n<p style=\"text-align: left;\"><span leaf=\"\" style=\"color: rgba(0, 0, 0, 0.9);font-size: 17px;font-family: mp-quote, &quot;PingFang SC&quot;, system-ui, -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;line-height: 1.6;letter-spacing: 0.034em;font-style: normal;font-weight: normal;\"><span textstyle=\"\" style=\"font-size: 16px;\">\u524d\u7aef\u6015\u7684\u4e0d\u662f\u63a5\u53e3\u62a5\u9519\uff0c\u662f\u63a5\u53e3&#8221;\u53c8\u6162\u53c8\u4e0d\u786e\u5b9a&#8221;\u7528&nbsp;<\/span><\/span><strong><span leaf=\"\" style=\"color: rgba(0, 0, 0, 0.9);font-size: 17px;font-family: mp-quote, &quot;PingFang SC&quot;, system-ui, -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;line-height: 1.6;letter-spacing: 0.034em;font-style: normal;font-weight: normal;\"><span textstyle=\"\" style=\"font-size: 12px;color: #0052ff;font-weight: bold;\">fixedDelayMilliseconds<\/span><\/span><\/strong><span leaf=\"\" style=\"color: rgba(0, 0, 0, 0.9);font-size: 17px;font-family: mp-quote, &quot;PingFang SC&quot;, system-ui, -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;line-height: 1.6;letter-spacing: 0.034em;font-style: normal;font-weight: normal;\"><span textstyle=\"\" style=\"font-size: 16px;\">&nbsp;\u8ba9\u63a5\u53e3 3 \u79d2\u540e\u624d\u8fd4\u56de\uff0c\u4e13\u95e8\u6d4b\u524d\u7aef\u7684 loading \u52a8\u753b\u3001\u8d85\u65f6\u63d0\u793a\u3001\u91cd\u8bd5\u903b\u8f91<\/span><\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"json\"><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"request\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"method\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"GET\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;<span class=\"code-snippet__attr\">\"urlPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\/api\/products\"<\/span>&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"response\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"status\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">200<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"fixedDelayMilliseconds\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">3000<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u5ef6\u8fdf 3 \u79d2\u8fd4\u56de\uff0c\u6d4b\u524d\u7aef loading<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"jsonBody\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"code\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">0<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;<span class=\"code-snippet__attr\">\"data\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">[]<\/span>&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">fault_delay.json\uff0c\u6a21\u62df\u6162\u63a5\u53e3<\/span><\/span><\/span><\/section>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u5ef6\u8fdf\u8fd8\u80fd\u914d\u5408\u524d\u7aef\u57cb\u70b9\u4e00\u8d77\u6d4b\u3002\u6bd4\u5982\u8981\u6c42\u63a5\u53e3\u8d85\u8fc7 1 \u79d2\u5c31\u4e0a\u62a5\u4e00\u6b21&#8221;\u6162\u8bf7\u6c42&#8221;\u76d1\u63a7\uff0c\u4f60\u7528 Mock \u8bbe 1200 \u6beb\u79d2\u5ef6\u8fdf\uff0c\u5c31\u80fd\u7a33\u5b9a\u89e6\u53d1\u8fd9\u6761\u76d1\u63a7\u8def\u5f84\u3002\u771f\u5b9e\u73af\u5883\u60f3\u9020\u8fd9\u4e48\u51c6\u7684\u5ef6\u8fdf\uff0c\u51e0\u4e4e\u4e0d\u53ef\u80fd\u3002\u6240\u4ee5\u6545\u969c\u6a21\u62df\u4e0d\u662f\u9526\u4e0a\u6dfb\u82b1\uff0c\u5b83\u662f\u552f\u4e00\u80fd\u7a33\u5b9a\u590d\u73b0&#8221;\u5076\u53d1\u6162&#8221;\u7684\u624b\u6bb5\u3002\u628a\u6162\u63a5\u53e3\u7eb3\u5165\u7528\u4f8b\uff0c\u524d\u7aef\u7684\u52a0\u8f7d\u6001\u3001\u9aa8\u67b6\u5c4f\u3001\u8d85\u65f6\u515c\u5e95\uff0c\u624d\u771f\u80fd\u88ab\u9a8c\u8bc1\u5230<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5ef6\u8fdf\u8fd8\u6709\u968f\u673a\u73a9\u6cd5\uff1a\u9664\u4e86 fixedDelayMilliseconds \u56fa\u5b9a\u5ef6\u8fdf\uff0c\u4f60\u53ef\u4ee5\u7528 delayDistribution \u914d\u7f6e\u4e00\u4e2a\u968f\u673a\u533a\u95f4\uff0c\u6bd4\u5982 500 \u5230 2000 \u6beb\u79d2\u4e4b\u95f4\u6d6e\u52a8\u3002\u8fd9\u6837\u66f4\u63a5\u8fd1\u771f\u5b9e\u7f51\u7edc\u7684\u6296\u52a8\uff0c\u524d\u7aef loading \u548c\u8d85\u65f6\u903b\u8f91\u5728&#8221;\u6709\u65f6\u5feb\u6709\u65f6\u6162&#8221;\u4e0b\u624d\u66b4\u9732\u771f\u5b9e\u8868\u73b0\u3002\u56fa\u5b9a\u5ef6\u8fdf\u9002\u5408\u6d4b\u660e\u786e\u7684\u8d85\u65f6\u9608\u503c\uff0c\u968f\u673a\u5ef6\u8fdf\u9002\u5408\u6d4b\u9c81\u68d2\u6027\uff0c\u4e24\u8005\u90fd\u5907\u7740\u66f4\u597d<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">6.2 \u6a21\u62df\u9519\u8bef\u72b6\u6001\u7801<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u628a status \u6539\u6210 500\u3001403\u3001429\uff0c\u6d4b\u7cfb\u7edf\u5bf9\u5404\u7c7b\u9519\u8bef\u7684\u515c\u5e95\u3002\u6bd4\u5982 429 \u9650\u6d41\uff0c\u770b\u524d\u7aef\u6709\u6ca1\u6709\u53cb\u597d\u7684&#8221;\u64cd\u4f5c\u9891\u7e41&#8221;\u63d0\u793a\uff0c\u800c\u4e0d\u662f\u767d\u5c4f\uff1b500 \u65f6\u6709\u6ca1\u6709\u91cd\u8bd5\u6216\u964d\u7ea7<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6211\u7279\u522b\u5efa\u8bae\u628a 429 \u548c 503 \u4e5f\u7eb3\u5165\u3002\u8fd9\u4e24\u7c7b\u5728\u6d41\u91cf\u9ad8\u5cf0\u548c\u53d1\u5e03\u671f\u95f4\u5e38\u89c1\uff0c\u5374\u5bb9\u6613\u88ab\u5ffd\u7565\u3002\u524d\u7aef\u5bf9 429 \u7684\u5904\u7406\uff08\u9000\u907f\u91cd\u8bd5\u3001\u53cb\u597d\u63d0\u793a\uff09\u4e00\u65e6\u6ca1\u5199\u597d\uff0c\u7528\u6237\u4f53\u9a8c\u4f1a\u65ad\u5d16\u5f0f\u4e0b\u8dcc\u3002\u800c\u8fd9\u7c7b\u9519\u8bef\u5728\u6d4b\u8bd5\u73af\u5883\u51e0\u4e4e\u4e0d\u4f1a\u81ea\u7136\u51fa\u73b0\uff0c\u4f60\u4e0d\u4e3b\u52a8 Mock\uff0c\u5c31\u6c38\u8fdc\u6d4b\u4e0d\u5230\u3002\u6240\u4ee5\u9519\u8bef\u7801\u4e0d\u662f\u987a\u624b\u52a0\u7684\uff0c\u662f\u5fc5\u987b\u5217\u8fdb\u7528\u4f8b\u6e05\u5355\u7684<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">6.3 \u6a21\u62df\u7f51\u7edc\u4e2d\u65ad<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">WireMock \u8fd8\u80fd\u8fd4\u56de\u7a7a\u54cd\u5e94\u3001\u65ad\u8fde\u3001\u8fd4\u56de\u635f\u574f\u7684 body\u3002\u8fd9\u4e9b\u5728\u771f\u5b9e\u7f51\u7edc\u91cc\u5076\u5c14\u53d1\u751f\uff0c\u4f46\u771f\u5b9e\u73af\u5883\u5f88\u96be\u7a33\u5b9a\u590d\u73b0\u3002Mock \u8ba9\u4f60\u968f\u65f6\u4e00\u952e\u89e6\u53d1\uff0c\u628a\u5f02\u5e38\u8def\u5f84\u4e5f\u7eb3\u5165\u65e5\u5e38\u6d4b\u8bd5<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u5177\u4f53\u505a\u6cd5<\/span>\uff1a\u7528 response \u76f4\u63a5\u8fd4\u56de\u7a7a body\uff0c\u6216\u8bbe\u4e00\u4e2a\u6781\u77ed\u8d85\u65f6\u8ba9\u8fde\u63a5\u4e2d\u65ad\uff0c\u6216\u8fd4\u56de\u4e00\u6bb5\u975e JSON \u7684\u810f\u6570\u636e\u6d4b\u89e3\u6790\u5bb9\u9519\u3002\u8fd9\u4e9b\u5728\u771f\u5b9e\u73af\u5883\u91cc&#8221;\u770b\u8fd0\u6c14\u624d\u78b0\u5230&#8221;\uff0cMock \u8ba9\u4f60\u628a\u5b83\u4eec\u53d8\u6210&#8221;\u6bcf\u5929\u5fc5\u8dd1&#8221;\u3002\u6211\u89c1\u8fc7\u592a\u591a\u7cfb\u7edf\uff0c\u6b63\u5e38\u6d41\u7a0b\u7a33\u5982\u8001\u72d7\uff0c\u4e00\u9047\u5230\u810f\u6570\u636e\u5c31\u6574\u4e2a\u5d29\u6389\u2014\u2014\u6839\u56e0\u5c31\u662f\u6ca1\u4eba\u6d4b\u8fc7\u5f02\u5e38\u8def\u5f84\u3002Mock \u7684\u4ef7\u503c\uff0c\u4e00\u534a\u5728 happy path\uff0c\u53e6\u4e00\u534a\u6070\u6070\u5728\u8fd9\u4e9b\u9ebb\u70e6\u4e8b\u4e0a<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">6.4 \u6279\u91cf\u6545\u969c\u573a\u666f<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u4f60\u53ef\u4ee5\u4e00\u6b21\u6027\u5b9a\u4e49\u591a\u79cd\u6545\u969c\u6a21\u5f0f\uff0c\u7528\u968f\u673a\u6216\u8f6e\u8be2\u7b56\u7565\u8fd4\u56de\u3002\u914d\u5408\u81ea\u52a8\u5316\uff0c\u6bcf\u6b21\u6784\u5efa\u968f\u673a\u62bd\u4e00\u79cd\u6545\u969c\u6ce8\u5165\uff0c\u76f8\u5f53\u4e8e\u7ed9\u7cfb\u7edf\u505a&#8221;\u6df7\u6c8c\u6f14\u7ec3&#8221;\uff0c\u63d0\u524d\u66b4\u9732\u8106\u5f31\u70b9<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u7ecf\u9a8c\u4e4b\u8c08\uff1a\u628a\u6545\u969c\u6a21\u5f0f\u5199\u6210\u4e00\u7ec4 Stub\uff0c\u7528 priority \u548c\u968f\u673a\u7b56\u7565\u5207\u6362\u3002\u8fd9\u6837\u540c\u4e00\u5957\u81ea\u52a8\u5316\uff0c\u6bcf\u5929\u8dd1\u51fa\u6765\u7684&#8221;\u574f\u60c5\u51b5&#8221;\u90fd\u4e0d\u4e00\u6837\uff0c\u8986\u76d6\u66f4\u7acb\u4f53\u3002\u4e0d\u8fc7\u522b\u8d2a\u591a\u3002\u6545\u969c\u6a21\u5f0f\u592a\u591a\uff0c\u53cd\u800c\u63a9\u76d6\u91cd\u70b9\u3002\u6211\u4e00\u822c\u7ef4\u62a4 5 \u5230 8 \u4e2a\u5178\u578b\u6545\u969c\uff08\u6162\u3001500\u3001403\u3001429\u3001\u7a7a\u54cd\u5e94\uff09\uff0c\u8986\u76d6\u4f4f\u4e3b\u8981\u98ce\u9669\u5c31\u591f\u3002\u5269\u4e0b\u7684\u4ea4\u7ed9\u771f\u5b9e\u73af\u5883\u7684\u7070\u5ea6\u89c2\u5bdf\uff0cMock \u548c\u771f\u5b9e\u73af\u5883\u5404\u53f8\u5176\u804c\uff0c\u624d\u662f\u4e00\u4e2a\u5065\u5eb7\u7684\u8d28\u91cf\u4f53\u7cfb<\/span><\/p>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000717\" data-ratio=\"0.36666666666666664\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/BWmfcibGhS1IQNUNNdJJSBqmGevVrA6a8LLZzbIu2eyaQlEdARjicNvnAe55STSEpYLibn5iajMeWNye15esWicia95VT9ombd5QjpdVvXpA74ZNs\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">WireMock \u6545\u969c\u6ce8\u5165\u80fd\u529b\u5168\u666f\u2014\u2014\u8986\u76d6\u8d85\u65f6\u3001\u9519\u8bef\u7801\u3001\u7a7a\u54cd\u5e94\u3001\u810f\u6570\u636e\u7b49 6 \u7c7b\u5178\u578b\u6545\u969c<\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">07<\/span><\/span><span leaf=\"\">\u5b9e\u6218\uff1a\u652f\u4ed8\u7f51\u5173Mock\u5b8c\u6574\u6848\u4f8b<\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">7.1 \u80cc\u666f\uff1a\u652f\u4ed8\u63a5\u53e3\u4e0d\u7a33\u5b9a\uff0c\u6d4b\u8bd5\u88ab\u53cd\u590d\u963b\u585e<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u53bb\u5e74Q3\uff0c\u6211\u4eec\u56e2\u961f\u63a5\u4e86\u4e00\u4e2a\u7535\u5546\u7cfb\u7edf\u91cd\u6784\u9879\u76ee\uff0c\u6838\u5fc3\u94fe\u8def\u4e4b\u4e00\u662f\u652f\u4ed8\u3002\u652f\u4ed8\u4f9d\u8d56\u7b2c\u4e09\u65b9\u652f\u4ed8\u5b9d\/\u5fae\u4fe1\u63a5\u53e3\uff0c\u800c\u7b2c\u4e09\u65b9\u63a5\u53e3\u5728\u6d4b\u8bd5\u73af\u5883\u6709\u4e25\u683c\u7684\u98ce\u63a7\u9650\u5236\u2014\u2014\u6bcf\u5929\u53ea\u80fd\u8c03\u6709\u9650\u6b21\u6570\uff0c\u800c\u4e14\u54cd\u5e94\u65f6\u95f4\u4e0d\u7a33\u5b9a\uff0c\u7ecf\u5e38 3-5 \u79d2\u624d\u56de\u6765\uff0c\u5076\u53d1\u8d85\u65f6<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u95ee\u9898\u662f\uff1a\u652f\u4ed8\u63a5\u53e3\u4e00\u6162\u6216\u4e00\u8d85\u65f6\uff0c\u6211\u4eec\u7684\u96c6\u6210\u6d4b\u8bd5\u5c31\u5f00\u59cb\u968f\u673a\u5931\u8d25\u3002\u6bcf\u6b21 CI \u8dd1\u51fa\u6765\u7ea2\u8272\uff0c\u56e2\u961f\u7b2c\u4e00\u53cd\u5e94\u662f&#8221;\u662f\u4e0d\u662f\u7b2c\u4e09\u65b9\u63a5\u53e3\u53c8\u4e0d\u7a33\u5b9a\u4e86&#8221;\uff0c\u67e5\u534a\u5929\u53d1\u73b0\u662f\u6d4b\u8bd5\u73af\u5883\u7f51\u7edc\u6296\u52a8\uff0c\u6839\u672c\u4e0d\u662f\u4ee3\u7801\u95ee\u9898\u3002\u8fd9\u79cd&#8221;\u72fc\u6765\u4e86&#8221;\u7684\u60c5\u51b5\u6301\u7eed\u4e86\u4e24\u5468\uff0c\u5927\u5bb6\u5bf9\u7ea2\u8272\u8b66\u62a5\u7684\u654f\u611f\u5ea6\u4e25\u91cd\u4e0b\u964d\uff0c\u771f\u6b63\u7684\u95ee\u9898\u53cd\u800c\u88ab\u6df9\u6ca1\u4e86<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"576\">\n<p data-pm-slice=\"0 0 []\" style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 16px;font-weight: bold;\">\u270d \u8f6c\u6298\u70b9\uff1a\u4e00\u6b21\u5468\u4e94\u4e0b\u5348\u7684&#8221;\u652f\u4ed8\u6d4b\u8bd5\u5927\u5835\u585e&#8221;<\/span><\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6700\u4e25\u91cd\u7684\u4e00\u6b21\u662f\u5468\u4e94\u4e0b\u5348\uff0c\u4e34\u8fd1\u4e0a\u7ebf\u8282\u70b9\u3002\u7b2c\u4e09\u65b9\u652f\u4ed8\u7a81\u7136\u5f00\u59cb\u5927\u91cf\u8d85\u65f6\uff0cCI \u4e0a\u5341\u51e0\u6761\u652f\u4ed8\u76f8\u5173\u7528\u4f8b\u5168\u90e8\u7ea2\u6389\u3002\u524d\u7aef\u540c\u5b66\u6ca1\u6cd5\u8c03\u9875\u9762\uff0c\u540e\u7aef\u5728\u7b49\u63a5\u53e3\uff0c\u6d4b\u8bd5\u5728\u7b49\u4e24\u8fb9\u90fd\u7a33\u4e0b\u6765\u518d\u8dd1\uff0c\u4e09\u65b9\u540c\u65f6\u5361\u4f4f\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5f53\u65f6\u6211\u7d27\u6025\u628a\u6240\u6709\u652f\u4ed8\u76f8\u5173\u7684\u7528\u4f8b\u6539\u6210 Mock \u6a21\u5f0f\uff0c\u7528 WireMock \u628a\u7b2c\u4e09\u65b9\u63a5\u53e3 Mock \u6389\uff0c\u5207\u6362 BASE_URL\uff0c\u4e00\u4e2a\u5c0f\u65f6\u540e CI \u91cd\u65b0\u8dd1\u8d77\u6765\uff0c\u7ea2\u8272\u6d88\u5931\u3002\u90a3\u6b21\u4e4b\u540e\u6211\u5728\u56e2\u961f\u4f8b\u4f1a\u4e0a\u6b63\u5f0f\u63d0\u51fa\uff1a<\/span><strong><span leaf=\"\">\u652f\u4ed8\u94fe\u8def\u7684\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5fc5\u987b\u5168\u90e8 Mock\uff0c\u8fd9\u662f\u6d4b\u8bd5\u7a33\u5b9a\u6027\u7684\u57fa\u7840\u8bbe\u65bd\uff0c\u4e0d\u662f\u53ef\u9009\u9879\u3002<\/span><\/strong><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u56e2\u961f\u4e00\u81f4\u540c\u610f\uff0c\u4e4b\u540e\u518d\u4e5f\u6ca1\u6709\u56e0\u4e3a\u7b2c\u4e09\u65b9\u63a5\u53e3\u4e0d\u7a33\u5b9a\u5bfc\u81f4 CI \u5931\u8d25\u7684\u60c5\u51b5\u3002<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">7.2 Mock \u8bbe\u8ba1\u65b9\u6848<\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u652f\u4ed8\u7f51\u5173\u7684 Mock \u9700\u8981\u8986\u76d6\u4ee5\u4e0b\u573a\u666f\uff1a<\/span><\/p>\n<table style=\"width: 704px;border-collapse: collapse;margin: 20px 0px;font-size: 14px;background: rgb(255, 255, 255);color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\">\n<thead>\n<tr>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">\u573a\u666f<\/span><\/span><\/section>\n<\/th>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">\u63cf\u8ff0<\/span><\/span><\/section>\n<\/th>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">Mock \u54cd\u5e94<\/span><\/span><\/section>\n<\/th>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">\u6d4b\u8bd5\u76ee\u6807<\/span><\/span><\/section>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u652f\u4ed8\u6210\u529f<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u6b63\u5e38\u6536\u6b3e\u6210\u529f<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">code=0, paid=true, orderId \u56de\u586b<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u9a8c\u8bc1\u8ba2\u5355\u72b6\u6001\u53d8\u66f4\u6b63\u786e<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(246, 248, 251);\">\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4f59\u989d\u4e0d\u8db3<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u7528\u6237\u8d26\u6237\u4f59\u989d\u4e0d\u8db3<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">code=1002, msg=&#8221;\u4f59\u989d\u4e0d\u8db3&#8221;<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u9a8c\u8bc1\u524d\u7aef\u4f59\u989d\u63d0\u793a<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u98ce\u63a7\u62e6\u622a<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4ea4\u6613\u89e6\u53d1\u98ce\u63a7\u89c4\u5219<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">code=1003, msg=&#8221;\u4ea4\u6613\u53d7\u9650&#8221;<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u9a8c\u8bc1\u98ce\u63a7\u63d0\u793a\u4e0e\u5904\u7406<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(246, 248, 251);\">\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u652f\u4ed8\u8d85\u65f6<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u7b2c\u4e09\u65b9\u63a5\u53e3\u8d85\u65f6<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">fixedDelay=8000ms<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u9a8c\u8bc1\u8d85\u65f6\u515c\u5e95\u903b\u8f91<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u7f51\u7edc\u4e2d\u65ad<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u8fd4\u56de\u7a7a body<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">body=&#8221;&#8221;, status=504<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u9a8c\u8bc1\u65ad\u8fde\u5bb9\u9519<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(246, 248, 251);\">\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u5e76\u53d1\u91cd\u590d\u652f\u4ed8<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u540c\u4e00\u8ba2\u5355\u91cd\u590d\u63d0\u4ea4<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">code=1004, msg=&#8221;\u8ba2\u5355\u5df2\u652f\u4ed8&#8221;<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u9a8c\u8bc1\u5e42\u7b49\u6027<\/span><\/section>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<section style=\"text-indent: 2em;\"><span style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u6211\u6309\u7167\u8fd9\u4e2a\u8868\u683c\uff0c\u9010\u4e2a\u573a\u666f\u5199 Stub \u6587\u4ef6\uff1apay_success.json\u3001pay_fail_balance.json\u3001pay_fail_risk.json\u3001pay_timeout.json\u3001pay_network_error.json\u3001pay_duplicate.json\u3002\u6587\u4ef6\u540d\u89c1\u540d\u77e5\u610f\uff0c\u65b9\u4fbf\u540e\u7eed\u7ef4\u62a4<\/span><\/span><\/section>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">7.3 \u5b9e\u73b0\u8fc7\u7a0b<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u7b2c\u4e00\u6b65\uff1a<\/span>\u68b3\u7406\u652f\u4ed8\u63a5\u53e3\u5951\u7ea6\u3002\u8ddf\u540e\u7aef\u540c\u5b66\u8981\u5230\u4e86\u7b2c\u4e09\u65b9\u652f\u4ed8\u7684\u63a5\u53e3\u6587\u6863\uff0c\u786e\u8ba4\u4e86\u8bf7\u6c42\u53c2\u6570\uff08orderId\u3001amount\u3001channel\u3001userId\uff09\u548c\u54cd\u5e94\u5b57\u6bb5\uff08code\u3001msg\u3001data{paid, transactionId, paidAt}\uff09\u3002\u8fd9\u662f Mock \u7684\u524d\u63d0\u2014\u2014\u4f60\u5f97\u77e5\u9053\u771f\u5b9e\u7684\u5951\u7ea6\u957f\u4ec0\u4e48\u6837\uff0c\u624d\u80fd Mock \u5f97\u51c6<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u7b2c\u4e8c\u6b65\uff1a<\/span>\u5199 Stub \u6587\u4ef6\u3002\u652f\u4ed8\u6210\u529f Stub \u662f\u6574\u6761\u94fe\u8def\u7684\u57fa\u7840\uff0c\u6838\u5fc3\u662f\u56de\u586b orderId\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"json\"><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"scenarioName\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"PaymentFlow\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"request\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"method\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"POST\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"urlPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\/api\/pay\/gateway\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"bodyPatterns\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">[<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"matchesJsonPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"$.orderId\"<\/span>&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">]<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"response\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"status\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">200<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"jsonBody\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"code\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">0<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"msg\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\u652f\u4ed8\u6210\u529f\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"data\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"paid\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__literal\"><span class=\"code-snippet__keyword\">true<\/span><\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"transactionId\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"{{randomValue length=32 type='ALPHANUMERIC'}}\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"paidAt\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"{{now format='yyyy-MM-dd HH:mm:ss'}}\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"transformers\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">[<\/span><span class=\"code-snippet__string\">\"response-template\"<\/span><span class=\"code-snippet__punctuation\">]<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">pay_success.json\uff0c\u652f\u4ed8\u6210\u529f Stub\uff08\u56de\u586b orderId\uff0c\u751f\u6210\u968f\u673a transactionId\uff09<\/span><\/span><\/span><\/section>\n<section><span style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">\u7b2c\u4e09\u6b65\uff1a<\/span>\u5199\u5931\u8d25\u573a\u666f Stub\u3002\u6bd4\u5982\u4f59\u989d\u4e0d\u8db3\u7684 Stub\uff0cpriority \u8bbe\u4f4e\uff08\u9ad8\u4f18\u5148\u7ea7\uff09\uff0c\u786e\u4fdd\u5b83\u6bd4\u6210\u529f Stub \u66f4\u5bb9\u6613\u5339\u914d\uff1a<\/span><\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"json\"><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"priority\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">1<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"code-snippet__comment\">\/\/ \u9ad8\u4f18\u5148\u7ea7\uff0c\u4f18\u5148\u5339\u914d<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"request\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"method\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"POST\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"urlPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\/api\/pay\/gateway\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"bodyPatterns\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">[<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">{<\/span>&nbsp;<span class=\"code-snippet__attr\">\"matchesJsonPath\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"$.amount\"<\/span><span class=\"code-snippet__punctuation\">,<\/span>&nbsp;<span class=\"code-snippet__attr\">\"greaterThan\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">10000<\/span>&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">]<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">},<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">\"response\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"status\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">200<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"jsonBody\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__punctuation\">{<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"code\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__number\">1002<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"msg\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__string\">\"\u4f59\u989d\u4e0d\u8db3\"<\/span><span class=\"code-snippet__punctuation\">,<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">\"data\"<\/span><span class=\"code-snippet__punctuation\">:<\/span>&nbsp;<span class=\"code-snippet__literal\"><span class=\"code-snippet__keyword\">null<\/span><\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__punctuation\">}<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">pay_fail_balance.json\uff0c\u4f59\u989d\u4e0d\u8db3 Stub\uff08\u6309\u91d1\u989d\u6761\u4ef6\u5206\u6d41\uff09<\/span><\/span><\/span><\/section>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u8fd9\u91cc\u7528 bodyPatterns \u7684 greaterThan \u5339\u914d\u91d1\u989d\u2014\u2014\u5f53 amount &gt; 10000 \u65f6\u89e6\u53d1\u4f59\u989d\u4e0d\u8db3\u573a\u666f\u3002\u4f60\u8fd8\u53ef\u4ee5\u6269\u5c55\u6210\u7cbe\u786e\u91d1\u989d\u5339\u914d\uff08equalToJson\uff09\u6216\u91d1\u989d\u533a\u95f4\u5339\u914d\uff0c\u8ba9\u4e0d\u540c\u6d4b\u8bd5\u7528\u4f8b\u547d\u4e2d\u4e0d\u540c\u7684\u5931\u8d25 Stub<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">7.4 \u6d4b\u8bd5\u6267\u884c\uff1a\u516d\u573a\u666f\u5168\u8986\u76d6<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u516d\u4e2a\u573a\u666f\uff0c\u6211\u5199\u4e86\u516d\u6761 Pytest \u7528\u4f8b\uff0c\u6bcf\u6761\u5bf9\u5e94\u4e00\u4e2a Stub\uff0c\u901a\u8fc7\u5207\u6362 BASE_URL \u6216\u8c03\u6574\u8bf7\u6c42\u4f53\u89e6\u53d1\u5bf9\u5e94 Mock\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"python\"><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;requests<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;pytest<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;os<\/span><\/code><code><span leaf=\"\">BASE_URL = os.getenv(<span class=\"code-snippet__string\">\"PAY_BASE_URL\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"http:\/\/localhost:8080\"<\/span>)<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_pay_success<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u652f\u4ed8\u6210\u529f\uff1a\u9a8c\u8bc1\u8ba2\u5355\u72b6\u6001\u53d8\u66f4\u4e3a\u5df2\u652f\u4ed8\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; resp = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/pay\/gateway\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"orderId\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"ORD001\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"amount\"<\/span>:&nbsp;<span class=\"code-snippet__number\">99.0<\/span>,&nbsp;<span class=\"code-snippet__string\">\"channel\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"alipay\"<\/span>},<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;resp.status_code ==&nbsp;<span class=\"code-snippet__number\">200<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; body = resp.json()<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;body[<span class=\"code-snippet__string\">\"code\"<\/span>] ==&nbsp;<span class=\"code-snippet__number\">0<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;body[<span class=\"code-snippet__string\">\"data\"<\/span>][<span class=\"code-snippet__string\">\"paid\"<\/span>]&nbsp;<span class=\"code-snippet__keyword\">is<\/span>&nbsp;<span class=\"code-snippet__literal\">True<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;<span class=\"code-snippet__string\">\"transactionId\"<\/span>&nbsp;<span class=\"code-snippet__keyword\">in<\/span>&nbsp;body[<span class=\"code-snippet__string\">\"data\"<\/span>]<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_pay_balance_insufficient<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u4f59\u989d\u4e0d\u8db3\uff1a\u91d1\u989d &gt; 10000 \u89e6\u53d1\u4f59\u989d\u4e0d\u8db3 Mock\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; resp = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/pay\/gateway\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"orderId\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"ORD002\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"amount\"<\/span>:&nbsp;<span class=\"code-snippet__number\">15000.0<\/span>,&nbsp;<span class=\"code-snippet__string\">\"channel\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"wechat\"<\/span>},<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; body = resp.json()<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;body[<span class=\"code-snippet__string\">\"code\"<\/span>] ==&nbsp;<span class=\"code-snippet__number\">1002<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;<span class=\"code-snippet__string\">\"\u4f59\u989d\u4e0d\u8db3\"<\/span>&nbsp;<span class=\"code-snippet__keyword\">in<\/span>&nbsp;body[<span class=\"code-snippet__string\">\"msg\"<\/span>]<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_pay_timeout<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u652f\u4ed8\u8d85\u65f6\uff1a\u6a21\u62df\u7b2c\u4e09\u65b9\u63a5\u53e3\u5ef6\u8fdf 8 \u79d2\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; resp = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/pay\/gateway\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;json={<span class=\"code-snippet__string\">\"orderId\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"ORD003\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"amount\"<\/span>:&nbsp;<span class=\"code-snippet__number\">50.0<\/span>,&nbsp;<span class=\"code-snippet__string\">\"channel\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"alipay\"<\/span>},<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;timeout=<span class=\"code-snippet__number\">10<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u5982\u679c\u914d\u7f6e\u4e86 8 \u79d2\u5ef6\u8fdf\uff0c10 \u79d2\u5185\u4f1a\u6536\u5230\u54cd\u5e94\uff08200\uff09<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u5982\u679c\u6ca1\u914d\u7f6e Mock\uff0c\u8fd4\u56de 504 \u6216\u8d85\u65f6<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;resp.elapsed.total_seconds() &gt;&nbsp;<span class=\"code-snippet__number\">7.5<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">def<\/span>&nbsp;<span class=\"code-snippet__title\">test_pay_duplicate<\/span>():<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__string\">\"\"\"\u91cd\u590d\u652f\u4ed8\uff1a\u540c\u4e00 orderId \u7b2c\u4e8c\u6b21\u652f\u4ed8\u5e94\u8fd4\u56de\u5e42\u7b49\u9519\u8bef\"\"\"<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u7b2c\u4e00\u6b21\u652f\u4ed8\uff1aMock \u4f1a\u751f\u6210 transactionId \u5e76\u5207\u6362\u72b6\u6001<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r1 = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/pay\/gateway\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; json={<span class=\"code-snippet__string\">\"orderId\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"ORD004\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"amount\"<\/span>:&nbsp;<span class=\"code-snippet__number\">88.0<\/span>}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;r1.json()[<span class=\"code-snippet__string\">\"code\"<\/span>] ==&nbsp;<span class=\"code-snippet__number\">0<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__comment\"># \u7b2c\u4e8c\u6b21\u540c\u4e00\u8ba2\u5355\uff1aMock \u72b6\u6001\u673a\u5e94\u8fd4\u56de\u5df2\u652f\u4ed8<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; r2 = requests.post(<span class=\"code-snippet__string\">f\"<\/span><span class=\"code-snippet__string\"><span class=\"code-snippet__subst\">{BASE_URL}<\/span><\/span><span class=\"code-snippet__string\">\/api\/pay\/gateway\"<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; json={<span class=\"code-snippet__string\">\"orderId\"<\/span>:&nbsp;<span class=\"code-snippet__string\">\"ORD004\"<\/span>,&nbsp;<span class=\"code-snippet__string\">\"amount\"<\/span>:&nbsp;<span class=\"code-snippet__number\">88.0<\/span>}, timeout=<span class=\"code-snippet__number\">5<\/span>)<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; body2 = r2.json()<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;body2[<span class=\"code-snippet__string\">\"code\"<\/span>] ==&nbsp;<span class=\"code-snippet__number\">1004<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">assert<\/span>&nbsp;<span class=\"code-snippet__string\">\"\u5df2\u652f\u4ed8\"<\/span>&nbsp;<span class=\"code-snippet__keyword\">in<\/span>&nbsp;body2[<span class=\"code-snippet__string\">\"msg\"<\/span>]<\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">pytest_payment.py\uff0c\u516d\u573a\u666f\u652f\u4ed8 Mock \u5b8c\u6574\u6d4b\u8bd5\u811a\u672c<\/span><\/span><\/span><\/section>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">7.5 \u5207\u6362\u5230\u771f\u5b9e\u73af\u5883<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">Mock \u8dd1\u901a\u4e4b\u540e\uff0c\u7d27\u63a5\u7740\u8981\u505a\u7684\u4e00\u6b65\u662f\uff1a<\/span><strong><span leaf=\"\">\u5207\u6362\u56de\u771f\u5b9e\u73af\u5883\u505a\u56de\u5f52<\/span><\/strong><span leaf=\"\">\u3002Mock \u53ea\u80fd\u9a8c\u8bc1\u5951\u7ea6\uff0c\u4e0d\u80fd\u9a8c\u8bc1\u7b2c\u4e09\u65b9\u771f\u5b9e\u7684\u4e1a\u52a1\u89c4\u5219\uff08\u6bd4\u5982\u98ce\u63a7\u6a21\u578b\u3001\u8d26\u6237\u72b6\u6001\uff09<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5207\u6362\u65b9\u6cd5\u5f88\u7b80\u5355\uff1a\u6539\u4e00\u884c\u73af\u5883\u53d8\u91cf\u3002BASE_URL \u4ece http:\/\/localhost:8080\uff08Mock\uff09\u6362\u6210 https:\/\/pay-api.example.com\uff08\u771f\u5b9e\u73af\u5883\uff09\uff0c\u5176\u4ed6\u4ee3\u7801\u4e00\u884c\u4e0d\u52a8\u3002\u771f\u5b9e\u73af\u5883\u8dd1\u5b8c\u4e4b\u540e\u8bb0\u5f97\u5207\u56de\u6765\uff0c\u5426\u5219 CI \u4f1a\u62ff\u771f\u5b9e\u63a5\u53e3\u8dd1\u81ea\u52a8\u5316\uff0c\u7b2c\u4e09\u65b9\u8d26\u6237\u4f1a\u6263\u771f\u5b9e\u94b1<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"576\">\n<p data-pm-slice=\"0 0 []\" style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 15px;font-weight: bold;\">\u270d&nbsp;<\/span><span textstyle=\"\" style=\"font-size: 15px;color: #7b0c00;font-weight: bold;\">\u4e00\u6b21\u5dee\u70b9&#8221;\u771f\u6263\u6b3e&#8221;\u7684\u6559\u8bad<\/span><\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6709\u4e00\u6b21\u8054\u8c03\u7ed3\u675f\uff0c\u6211\u5fd8\u4e86\u628a BASE_URL \u5207\u56de Mock\uff0c\u81ea\u52a8\u5316\u7ee7\u7eed\u8dd1\u3002\u7ed3\u679c\u534a\u591c CI \u6267\u884c\u4e86\u4e00\u6761\u771f\u5b9e\u652f\u4ed8\u7528\u4f8b\uff0c\u7528\u7684\u662f\u6d4b\u8bd5\u73af\u5883\u7684\u6c99\u7bb1\u8d26\u53f7\uff0c\u672c\u6765\u4e0d\u4f1a\u771f\u6263\u94b1\u2014\u2014\u4f46\u6d4b\u8bd5\u73af\u5883\u7684\u6c99\u7bb1\u914d\u7f6e\u6709\u95ee\u9898\uff0c\u8d70\u4e86\u771f\u5b9e\u652f\u4ed8\u901a\u9053\uff0c\u8d26\u6237\u88ab\u6263\u4e86\u51e0\u5757\u94b1\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u94b1\u4e0d\u591a\uff0c\u4f46\u6027\u8d28\u4e25\u91cd\u3002\u7b2c\u4e8c\u5929\u6211\u7acb\u523b\u52a0\u4e86\u4fdd\u62a4\uff1a\u5728\u771f\u5b9e\u73af\u5883 BASE_URL \u4e0b\uff0c\u81ea\u52a8\u5316\u9047\u5230\u652f\u4ed8\u7c7b\u63a5\u53e3\u76f4\u63a5\u8df3\u8fc7\u5e76\u6253\u6807\uff0c\u7edd\u4e0d\u81ea\u52a8\u6267\u884c\u771f\u652f\u4ed8\u64cd\u4f5c\u3002\u8fd9\u4e2a\u4fdd\u62a4\u540e\u6765\u53c8\u6551\u4e86\u6211\u4eec\u4e00\u6b21\u2014\u2014\u6709\u4e00\u6b21 CI \u914d\u7f6e\u9519\u8bef\u8bef\u6307\u5411\u4e86\u751f\u4ea7\u73af\u5883\uff0c\u81ea\u52a8\u5316\u81ea\u52a8\u8df3\u8fc7\u4e86\u6240\u6709\u5199\u64cd\u4f5c\uff0c\u6ca1\u6709\u9020\u6210\u4efb\u4f55\u635f\u5931\u3002<\/span><\/p>\n<p style=\"margin: 6px 0px;font-size: 14px;color: rgb(52, 73, 94);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u6559\u8bad\uff1a\u73af\u5883\u5207\u6362\u662f\u81ea\u52a8\u5316\u7684\u547d\u95e8\uff0c\u5199\u6b7b\u5728\u4ee3\u7801\u91cc\u4e0d\u5982\u7528\u73af\u5883\u53d8\u91cf\u7ba1\u7406\uff0c\u52a0\u4e00\u5c42\u65ad\u8a00\u4fdd\u62a4\u66f4\u7a33\u59a5\u3002<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<section style=\"text-indent: 2em;\"><span style=\"color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u771f\u5b9e\u7684\u652f\u4ed8\u7f51\u5173\u56de\u5f52\uff0c\u6211\u4e00\u822c\u5206\u4e09\u6b65\u8d70\uff1a\u7b2c\u4e00\u6b65\u7528 Mock \u628a\u6838\u5fc3\u7528\u4f8b\u5168\u90e8\u8dd1\u901a\uff1b\u7b2c\u4e8c\u6b65\u5207\u6362\u771f\u5b9e\u73af\u5883\uff0c\u8dd1\u5173\u952e\u7684 happy path\uff08\u652f\u4ed8\u6210\u529f\u3001\u652f\u4ed8\u5931\u8d25\uff09\uff1b\u7b2c\u4e09\u6b65\u90e8\u7f72\u5230\u9884\u53d1\u5e03\u73af\u5883\uff0c\u7528\u771f\u5b9e\u7b2c\u4e09\u65b9\u8d26\u53f7\u8dd1\u4e00\u6b21\u7aef\u5230\u7aef\u3002Mock \u8d1f\u8d23&#8221;\u5feb\u901f\u9a8c\u8bc1\u5951\u7ea6&#8221;\uff0c\u771f\u5b9e\u73af\u5883\u8d1f\u8d23&#8221;\u9a8c\u8bc1\u5b8c\u6574\u4e1a\u52a1\u903b\u8f91&#8221;\uff0c\u4e8c\u8005\u5404\u53f8\u5176\u804c\uff0c\u624d\u662f\u5065\u5eb7\u7684\u6d4b\u8bd5\u5206\u5c42\u3002<\/span><\/span><\/section>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000718\" data-ratio=\"0.4305555555555556\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/BWmfcibGhS1JA6QG9RkIA7rZhsI8zUUz8EgaSBv7SgEV6KfxzRF87oBHI5jjEnG6IiaHDmyPHW4f8I7xT0zbWroQVk9wmbickcuhExUKCxtQHs\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: center;\"><span style=\"color: rgb(111, 125, 150);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 13px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">\u652f\u4ed8\u7f51\u5173 Mock \u5b8c\u6574\u6d41\u7a0b\u2014\u2014\u5951\u7ea6\u68b3\u7406 \u2192 Stub \u5b9e\u73b0 \u2192 \u81ea\u52a8\u5316\u9a8c\u8bc1 \u2192 \u771f\u5b9e\u73af\u5883\u56de\u5f52\uff0c\u56db\u6b65\u5f62\u6210\u95ed\u73af<\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-size: 21px;color: rgb(15, 52, 96);margin: 44px 0px 18px;padding-left: 14px;border-left: 5px solid rgb(79, 195, 247);line-height: 1.4;font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(255, 167, 38);font-weight: 700;margin-right: 8px;\"><span leaf=\"\">08<\/span><\/span><span leaf=\"\">\u907f\u5751\u4e0e\u884c\u52a8\u6e05\u5355<\/span><\/h2>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: bold;\">8.1 \u56db\u4e2a\u5e38\u89c1\u5751<\/span><\/span><\/h3>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(0, 82, 255);\">\u57511\uff1aMock \u6570\u636e\u548c\u771f\u5b9e\u63a5\u53e3\u6f02\u79fb\u3002<\/span><\/span><\/strong><span leaf=\"\">Mock \u5199\u4e45\u4e86\uff0c\u5bb9\u6613\u548c\u771f\u5b9e\u63a5\u53e3&#8221;\u957f\u5f97\u4e0d\u4e00\u6837&#8221;\u3002\u67d0\u5929\u540e\u7aef\u6539\u4e86\u5b57\u6bb5\u540d\uff0c\u4f60\u7684 Mock \u8fd8\u505c\u5728\u65e7\u7248\uff0c\u6d4b\u8bd5\u5168\u8fc7\u4f46\u4e0a\u7ebf\u5c31\u6302\u3002\u5bf9\u7b56\uff1a\u5b9a\u671f\u7528\u771f\u5b9e\u63a5\u53e3\u56de\u5f52\uff0c\u62ff\u771f\u5b9e\u54cd\u5e94\u548c Mock \u505a diff\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u5177\u4f53\u600e\u4e48\u505a diff\uff1f\u63a5\u53e3\u7a33\u5b9a\u540e\uff0c\u6293\u4e00\u4efd\u771f\u5b9e\u54cd\u5e94\u5b58\u4e0b\u6765\uff0c\u8ddf Mock \u7684 jsonBody \u9010\u5b57\u6bb5\u6bd4\u5bf9\u3002\u5b57\u6bb5\u540d\u3001\u7c7b\u578b\u3001\u7ed3\u6784\uff0c\u6709\u4efb\u4f55\u4e0d\u4e00\u81f4\u5c31\u6807\u7ea2\u3002\u6211\u7528\u4e00\u4e2a\u7b80\u5355\u811a\u672c\u6bcf\u5468\u8dd1\u4e00\u6b21\uff0c\u7701\u5f97\u4eba\u8089\u5bf9\u7740\u770b\u3002\u8fd9\u4e00\u6b65\u770b\u4f3c\u9ebb\u70e6\uff0c\u5374\u80fd\u62e6\u4f4f\u4e00\u7c7b\u9690\u853d\u7684&#8221;Mock \u7eff\u3001\u7ebf\u4e0a\u6302&#8221;\u4e8b\u6545\uff0c\u503c\u5f97\u5e38\u6001\u5316\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(0, 82, 255);\">\u57512\uff1a\u5fd8\u8bb0\u5207\u6362\u56de\u771f\u5b9e\u73af\u5883\u3002<\/span><\/span><\/strong><span leaf=\"\">\u6d4b\u8bd5\u8dd1\u5b8c\uff0c\u914d\u7f6e\u8fd8\u6307\u5411 Mock\uff0c\u7ed3\u679c\u8054\u8c03\u65f6\u8c03\u7684\u662f\u5047\u63a5\u53e3\uff0c\u6392\u67e5\u534a\u5929\u624d\u53d1\u73b0\u3002\u5bf9\u7b56\uff1a\u7528\u73af\u5883\u53d8\u91cf\u7ba1\u7406 BASE_URL\uff0c\u6d4b\u8bd5\u73af\u5883\u548c\u8054\u8c03\u73af\u5883\u4e00\u952e\u5207\u6362\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u66f4\u7a33\u59a5\u7684\u662f\u5728\u7528\u4f8b\u5c42\u505a\u65ad\u8a00\u4fdd\u62a4\uff1a\u5982\u679c\u68c0\u6d4b\u5230\u5f53\u524d BASE_URL \u6307\u5411\u771f\u5b9e\u73af\u5883\uff0c\u5173\u952e\u5199\u64cd\u4f5c\uff08\u4e0b\u5355\u3001\u652f\u4ed8\uff09\u81ea\u52a8\u8df3\u8fc7\u6216\u6253\u6807\u3002\u8fd9\u6837\u5c31\u7b97\u5fd8\u4e86\u5207\uff0c\u4e5f\u4e0d\u4f1a\u62ff\u771f\u5b9e\u73af\u5883\u505a\u7834\u574f\u6027\u6d4b\u8bd5\u3002\u8fd9\u6761\u5c24\u5176\u91cd\u8981\u2014\u2014\u6211\u66fe\u89c1\u8fc7\u6709\u4eba\u628a Mock \u914d\u7f6e\u7559\u5230\u4e86\u751f\u4ea7\u9a8c\u8bc1\u73af\u8282\uff0c\u5dee\u70b9\u5bf9\u771f\u5b9e\u5e93\u4e0b\u4e86\u5355\u3002\u73af\u5883\u9694\u79bb\u4e0d\u662f\u541b\u5b50\u534f\u5b9a\uff0c\u8981\u5199\u6210\u4ee3\u7801\u786c\u7ea6\u675f\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(0, 82, 255);\">\u57513\uff1aWireMock \u72b6\u6001\u4e22\u5931\u3002<\/span><\/span><\/strong><span leaf=\"\">Docker \u5bb9\u5668\u91cd\u542f\uff0c\u6ca1\u6302\u8f7d volume\uff0c\u6240\u6709 Stub \u914d\u7f6e\u84b8\u53d1\u3002\u5bf9\u7b56\uff1adocker-compose \u6302\u8f7d mappings \u548c __files \u76ee\u5f55\uff0c\u914d\u7f6e\u6301\u4e45\u5316\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8fd8\u6709\u4e2a\u76f8\u5173\u7684\u5c0f\u5751\uff1a\u5bb9\u5668\u540d\u51b2\u7a81\u3002\u7b2c\u4e8c\u6b21 docker run \u540c\u540d\u5b57\u62a5\u5df2\u5b58\u5728\uff0c\u8bb0\u5f97\u5148 docker rm \u65e7\u7684\uff0c\u6216\u5e72\u8106\u7528 compose \u7edf\u4e00\u7ba1\u7406\u751f\u547d\u5468\u671f\uff0c\u5c11\u624b\u52a8\u6572\u547d\u4ee4\u3002\u628a\u8d77\u505c\u90fd\u6536\u8fdb\u4e00\u6761 compose \u547d\u4ee4\uff0c\u65b0\u4eba\u7167\u7740\u6587\u6863\u8dd1\u4e5f\u51fa\u4e0d\u4e86\u9519\uff0c\u8fd9\u624d\u662f\u56e2\u961f\u53ef\u590d\u7528\u7684\u6837\u5b50\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><strong><span leaf=\"\"><span textstyle=\"\" style=\"font-weight: normal;\">\u57514\uff1aMock \u54cd\u5e94\u592a\u7b80\u5355\u3002<\/span><\/span><\/strong><span leaf=\"\">\u53ea\u8fd4\u56de 200 \u548c happy path\uff0c\u771f\u5b9e\u4e16\u754c\u7684 500\u3001\u8d85\u65f6\u3001\u9650\u6d41\u5168\u6ca1\u8986\u76d6\u3002\u5bf9\u7b56\uff1a\u628a\u7b2c\u516d\u7ae0\u7684\u6545\u969c\u6a21\u62df\u7eb3\u5165\u65e5\u5e38\uff0cMock \u4e5f\u8981&#8221;\u5236\u9020\u9ebb\u70e6&#8221;\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8bf4\u767d\u4e86\uff0cMock \u4e0d\u662f\u8d8a\u7eff\u8d8a\u597d\u3002\u5982\u679c\u4f60\u7684 Mock \u6c38\u8fdc\u53ea\u8fd4\u56de\u6210\u529f\uff0c\u90a3\u5b83\u9a8c\u8bc1\u7684\u53ea\u662f&#8221;\u4ee3\u7801\u5728\u7406\u60f3\u73af\u5883\u4e0b\u80fd\u8dd1&#8221;\u3002\u771f\u6b63\u7684\u8d28\u91cf\uff0c\u662f\u5728\u5404\u79cd\u9ebb\u70e6\u91cc\u8fd8\u80fd\u7a33\u4f4f\u3002\u6240\u4ee5\u522b\u628a Mock \u5f53\u6210\u8ba9\u6d4b\u8bd5\u53d8\u7eff\u7684\u5de5\u5177\uff0c\u8981\u628a\u5b83\u5f53\u6210\u5e2e\u4f60\u60f3\u5168\u5f02\u5e38\u7684\u5de5\u5177\u2014\u2014\u5b83\u903c\u7740\u4f60\u95ee\u4e00\u53e5\uff1a\u5982\u679c\u8fd9\u4e00\u6b65\u5931\u8d25\u4e86\uff0c\u7cfb\u7edf\u4f1a\u600e\u6837\uff1f<\/span><\/p>\n<h3 style=\"font-size: 17px;color: rgb(22, 33, 62);margin: 28px 0px 12px;padding-left: 10px;border-left: 3px solid rgb(255, 167, 38);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">8.2 \u5de5\u5177\u5bf9\u6bd4<\/span><\/h3>\n<table style=\"width: 704px;border-collapse: collapse;margin: 20px 0px;font-size: 14px;background: rgb(255, 255, 255);color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\">\n<thead>\n<tr>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">\u7ef4\u5ea6<\/span><\/span><\/section>\n<\/th>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">WireMock<\/span><\/span><\/section>\n<\/th>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">Postman Mock<\/span><\/span><\/section>\n<\/th>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">Mockito<\/span><\/span><\/section>\n<\/th>\n<th style=\"background: rgb(22, 33, 62);color: rgb(255, 255, 255);padding: 11px 12px;text-align: left;font-weight: 600;\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: rgb(214, 168, 65);\">Mountebank<\/span><\/span><\/section>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u8fd0\u884c\u4f4d\u7f6e<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u672c\u5730\/\u5bb9\u5668<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4e91\u7aef\u8d26\u53f7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">JVM \u5185<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u672c\u5730\/\u5bb9\u5668<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(246, 248, 251);\">\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u72b6\u6001\u673a<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u652f\u6301<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4e0d\u652f\u6301<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u6709\u9650<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u652f\u6301<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u6545\u969c\u6ce8\u5165<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u5f3a<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u5f31<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4e2d<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u5f3a<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(246, 248, 251);\">\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u5ef6\u8fdf\u6a21\u62df<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u652f\u6301<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4e0d\u652f\u6301<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u652f\u6301<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u652f\u6301<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u9002\u7528\u5c42\u7ea7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">HTTP \u5951\u7ea6<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">HTTP \u5951\u7ea6<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4ee3\u7801\u5355\u5143<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u591a\u534f\u8bae<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(246, 248, 251);\">\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u56e2\u961f\u534f\u4f5c<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u914d\u7f6e\u6587\u4ef6\u5171\u4eab<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4f9d\u8d56\u8d26\u53f7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u4ee3\u7801\u5185<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px 12px;border-bottom: 1px solid rgb(232, 235, 240);\">\n<section><span leaf=\"\">\u914d\u7f6e\u6587\u4ef6\u5171\u4eab<\/span><\/section>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8868\u91cc\u51e0\u4e2a\u540d\u5b57\uff0c\u7b80\u5355\u8bf4\u4e00\u4e0b\u5b9a\u4f4d\u3002Mockito \u662f\u5355\u5143\u6d4b\u8bd5\u91cc\u7684\u5bf9\u8c61 Mock\uff0c\u8dd1\u5728 Java \u8fdb\u7a0b\u5185\uff0c\u9002\u5408\u6d4b\u67d0\u4e2a\u7c7b\u7684\u65b9\u6cd5\u903b\u8f91\uff1bMountebank \u548c WireMock \u7c7b\u4f3c\uff0c\u4e5f\u652f\u6301\u591a\u534f\u8bae\uff08TCP\u3001SMTP \u7b49\uff09\uff0c\u4f46\u5b66\u4e60\u66f2\u7ebf\u66f4\u9661\uff1bPostman Mock \u80dc\u5728\u548c\u63a5\u53e3\u8c03\u8bd5\u4e00\u4f53\uff0c\u4f46\u80fd\u529b\u6d45\u3002\u6211\u7684\u9009\u62e9\u903b\u8f91\u5f88\u7b80\u5355\uff1a\u63a5\u53e3\u5951\u7ea6\u5c42\u8981\u52a8\u6001\u3001\u8981\u72b6\u6001\u3001\u8981\u6545\u969c\u2014\u2014\u9009 WireMock\uff0c\u57fa\u672c\u591f\u7528\u4e14\u987a\u624b\u3002<\/span><\/p>\n<p style=\"margin: 15px 0px;color: rgb(44, 44, 58);font-family: -apple-system, BlinkMacSystemFont, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Segoe UI&quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 2em;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span leaf=\"\">\u8865\u5145\u4e00\u53e5\u9009\u578b\u5fc3\u6001\uff1a\u5de5\u5177\u5404\u6709\u7279\u70b9\uff0c\u6ca1\u6709\u54ea\u79cd\u5728\u6240\u6709\u573a\u666f\u90fd\u901a\u5403\uff0c\u5173\u952e\u662f\u770b\u5408\u4e0d\u5408\u9002\u3002\u5982\u679c\u4f60\u7684\u9879\u76ee\u5df2\u7ecf\u91cd\u5ea6\u4f9d\u8d56 Postman \u505a\u63a5\u53e3\u7ba1\u7406\uff0c\u5148\u7528 Postman Mock \u628a happy path \u6321\u4e0a\u4e5f\u6ca1\u95ee\u9898\uff1b\u7b49\u4f60\u9700\u8981\u72b6\u6001\u673a\u3001\u6545\u969c\u6ce8\u5165\u8fd9\u4e9b\u80fd\u529b\u65f6\uff0c\u518d\u8fc1\u79fb\u5230 WireMock \u4e0d\u8fdf\u3002\u5173\u952e\u662f\u522b\u8ba9&#8221;\u7b49\u63a5\u53e3&#8221;\u5361\u4f4f\u6d4b\u8bd5\uff0c\u81f3\u4e8e\u7528\u54ea\u4e2a\u5de5\u5177\uff0c\u80fd\u89e3\u51b3\u95ee\u9898\u5c31\u884c\u3002<\/span><\/p>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000719\" data-ratio=\"0.35555555555555557\" data-s=\"300,640\" data-type=\"png\" data-w=\"1080\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/BWmfcibGhS1KcxLGYjgrT0b1tbSplycgZQDBlSibNeFQY47B4YoHuGwtOCfNRuHA5PVeFDc15btoiayqFdKedZ2nmPUbMlu2uQibgBLpAT4YEick\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 \u4f60\u6709\u6ca1\u6709\u9047\u5230\u8fc7\u8fd9\u79cd\u5c40\u9762\uff1f\u5468\u4e09\u4e0a\u5348\uff0c\u540e\u7aef\u540c\u5b66\u5728\u7fa4\u91cc\u4e22\u4e00\u53e5\uff1a&#8221;\u767b\u5f55\u63a5\u53e3\u5468\u4e94\u624d\u80fd\u7ed9\uff0c\u518d\u7b49\u7b49\u3002&#038;#8 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":84,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-auto-tools"],"_links":{"self":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":2,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":194,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts\/85\/revisions\/194"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/media\/84"}],"wp:attachment":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}