{"id":2348,"date":"2024-10-11T17:25:45","date_gmt":"2024-10-11T09:25:45","guid":{"rendered":"https:\/\/www.openbyt.com\/?p=2348"},"modified":"2024-10-17T19:58:04","modified_gmt":"2024-10-17T11:58:04","slug":"wordpress-development-a-comprehensive-guide-to-automated-testing-and-continuous-integration","status":"publish","type":"post","link":"https:\/\/www.openbyt.com\/zh\/wordpress\u958b\u767c\u81ea\u52d5\u5316\u6e2c\u8a66\u548c\u6301\u7e8c\u6574\u5408\u7684\u5168\u9762\u6307\u5357","title":{"rendered":"WordPress\uff1a\u81ea\u52d5\u5316\u6e2c\u8a66\u8207 CI \u6307\u5357"},"content":{"rendered":"<p>\u5305\u62ec WordPress \u5728\u5167\u7684\u8edf\u9ad4\u958b\u767c\u5b8c\u5168\u4f9d\u8cf4\u624b\u52d5\u6e2c\u8a66\u7684\u6642\u4ee3\u5df2\u7d93\u7d50\u675f\u3002\u5f9e\u624b\u52d5\u6e2c\u8a66\u904e\u6e21\u5230\u81ea\u52d5\u5316\u6e2c\u8a66\u662f\u5c0d\u8edf\u9ad4\u958b\u767c\u5718\u968a\u4e0d\u65b7\u6f14\u9032\u7684\u9700\u6c42\u7684\u56de\u61c9\u3002\u9019\u7bc7\u6587\u7ae0\u4ee5\u521d\u5b78\u8005\u6613\u61c2\u7684\u65b9\u5f0f\uff0c\u8a73\u7d30\u6982\u8ff0\u70ba\u4ec0\u9ebc\u6703\u767c\u751f\u9019\u7a2e\u8f49\u8b8a\u3001\u81ea\u52d5\u5316\u6e2c\u8a66\u548c\u6301\u7e8c\u6574\u5408 (CI) \u5c0d WordPress \u958b\u767c\u7684\u597d\u8655\uff0c\u4ee5\u53ca\u5982\u4f55\u6709\u6548\u5730\u5be6\u4f5c\u9019\u4e9b\u5be6\u52d9\u3002<\/p><figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.28.16-A-realistic-and-engaging-illustration-showing-the-shift-from-manual-testing-to-automated-testing-in-software-development-specifically-for-WordPress.-.webp\" alt=\"\" class=\"wp-image-2356\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.28.16-A-realistic-and-engaging-illustration-showing-the-shift-from-manual-testing-to-automated-testing-in-software-development-specifically-for-WordPress.-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.28.16-A-realistic-and-engaging-illustration-showing-the-shift-from-manual-testing-to-automated-testing-in-software-development-specifically-for-WordPress.--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.28.16-A-realistic-and-engaging-illustration-showing-the-shift-from-manual-testing-to-automated-testing-in-software-development-specifically-for-WordPress.--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.28.16-A-realistic-and-engaging-illustration-showing-the-shift-from-manual-testing-to-automated-testing-in-software-development-specifically-for-WordPress.--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.28.16-A-realistic-and-engaging-illustration-showing-the-shift-from-manual-testing-to-automated-testing-in-software-development-specifically-for-WordPress.--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.28.16-A-realistic-and-engaging-illustration-showing-the-shift-from-manual-testing-to-automated-testing-in-software-development-specifically-for-WordPress.--768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>1.WordPress \u5f9e\u624b\u52d5\u6e2c\u8a66\u5230\u81ea\u52d5\u5316\u6e2c\u8a66\u7684\u8f49\u8b8a<\/strong><\/p><p>\u624b\u52d5\u6e2c\u8a66\u5c0d\u65bc\u77ad\u89e3\u61c9\u7528\u7a0b\u5f0f\u7684\u904b\u4f5c\u65b9\u5f0f\u975e\u5e38\u91cd\u8981\uff0c\u4f46\u5b83\u6709\u8a31\u591a\u9650\u5236\u3002\u5b83\u8017\u8cbb\u6642\u9593\u3001\u9700\u8981\u5927\u91cf\u8cc7\u6e90\uff0c\u800c\u4e14\u5bb9\u6613\u767c\u751f\u4eba\u70ba\u932f\u8aa4\uff0c\u5c24\u5176\u662f\u5728\u91cd\u8907\u7684\u60c5\u6cc1\u4e0b\u3002<\/p><p>\u81ea\u52d5\u5316\u6e2c\u8a66\u900f\u904e\u63d0\u4f9b\u5feb\u901f\u3001\u6709\u6548\u7387\u4e14\u4e00\u81f4\u7684 WordPress \u61c9\u7528\u7a0b\u5f0f\u6e2c\u8a66\u65b9\u5f0f\u4f86\u89e3\u6c7a\u9019\u4e9b\u554f\u984c\u3002\u7121\u8ad6\u60a8\u8981\u5efa\u7acb\u7684\u662f\u7c21\u55ae\u7684\u90e8\u843d\u683c\u6216\u662f\u8907\u96dc\u7684\u6703\u54e1\u5236\u7db2\u7ad9\uff0c\u81ea\u52d5\u5316\u6e2c\u8a66\u90fd\u80fd\u7bc0\u7701\u6642\u9593\u3001\u6e1b\u5c11\u932f\u8aa4\uff0c\u4e26\u5354\u52a9\u78ba\u4fdd\u60a8\u7684\u7db2\u7ad9\u529f\u80fd\u7b26\u5408\u9810\u671f\u3002<\/p><figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.40.38-A-conceptual-illustration-representing-automated-testing-in-software-development-for-WordPress.-The-image-should-show-efficiency-consistency-and-red.webp\" alt=\"\" class=\"wp-image-2359\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.40.38-A-conceptual-illustration-representing-automated-testing-in-software-development-for-WordPress.-The-image-should-show-efficiency-consistency-and-red.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.40.38-A-conceptual-illustration-representing-automated-testing-in-software-development-for-WordPress.-The-image-should-show-efficiency-consistency-and-red-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.40.38-A-conceptual-illustration-representing-automated-testing-in-software-development-for-WordPress.-The-image-should-show-efficiency-consistency-and-red-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.40.38-A-conceptual-illustration-representing-automated-testing-in-software-development-for-WordPress.-The-image-should-show-efficiency-consistency-and-red-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.40.38-A-conceptual-illustration-representing-automated-testing-in-software-development-for-WordPress.-The-image-should-show-efficiency-consistency-and-red-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.40.38-A-conceptual-illustration-representing-automated-testing-in-software-development-for-WordPress.-The-image-should-show-efficiency-consistency-and-red-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><h4 class=\"wp-block-heading\"><strong>1.1 \u70ba\u4f55\u8981\u904e\u6e21\u5230\u81ea\u52d5\u5316\u6e2c\u8a66\uff1f<\/strong><\/h4><ul class=\"wp-block-list\"><li><strong>\u6548\u7387\u6700\u5927\u5316<\/strong>:\u81ea\u52d5\u5316\u6e2c\u8a66\u53ef\u4ee5\u5feb\u901f\u57f7\u884c\u8a31\u591a\u6e2c\u8a66\u6848\u4f8b\uff0c\u8207\u624b\u52d5\u6e2c\u8a66\u76f8\u6bd4\uff0c\u53ef\u4ee5\u6e1b\u5c11\u6240\u9700\u7684\u6642\u9593\u548c\u7cbe\u529b\u3002<\/li>\n\n<li><strong>\u64f4\u5145\u6027<\/strong>:\u7576\u60a8\u7684\u7db2\u7ad9\u6216\u61c9\u7528\u7a0b\u5f0f\u8b8a\u5f97\u66f4\u8907\u96dc\u6642\uff0c\u81ea\u52d5\u5316\u6e2c\u8a66\u53ef\u4ee5\u8655\u7406\u66f4\u591a\u7684\u60c5\u5883\uff0c\u800c\u4e0d\u6703\u589e\u52a0\u958b\u767c\u5718\u968a\u7684\u5de5\u4f5c\u91cf\u3002<\/li>\n\n<li><strong>\u5bb9\u6613\u6574\u5408<\/strong>:\u81ea\u52d5\u5316\u6e2c\u8a66\u53ef\u7121\u7e2b\u6574\u5408\u5230\u958b\u767c\u7ba1\u9053\u4e2d\uff0c\u5feb\u901f\u5075\u6e2c\u4e26\u89e3\u6c7a\u932f\u8aa4\u3002\u9019\u5728\u66f4\u65b0\u983b\u7e41\u7684 Agile \u548c DevOps \u74b0\u5883\u4e2d\u81f3\u95dc\u91cd\u8981\u3002<\/li>\n\n<li><strong>\u53ef\u91cd\u8907\u4e14\u53ef\u9760<\/strong>:\u81ea\u52d5\u5316\u6e2c\u8a66\u53ef\u4ee5\u5728\u591a\u500b\u74b0\u5883\u4e2d\u91cd\u8907\u9032\u884c\uff0c\u78ba\u4fdd\u6240\u6709\u529f\u80fd\u90fd\u80fd\u5982\u9810\u671f\u822c\u6301\u7e8c\u904b\u4f5c\uff0c\u9019\u5c0d\u65bc\u64c1\u6709\u5404\u7a2e\u5916\u639b\u548c\u5ba2\u88fd\u5316\u529f\u80fd\u7684 WordPress \u7db2\u7ad9\u5c24\u5176\u91cd\u8981\u3002<\/li><\/ul><figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.42.54-A-conceptual-illustration-showing-the-advantages-of-automated-testing-for-WordPress-development.-The-image-should-depict-developers-using-automated-to.webp\" alt=\"\" class=\"wp-image-2360\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.42.54-A-conceptual-illustration-showing-the-advantages-of-automated-testing-for-WordPress-development.-The-image-should-depict-developers-using-automated-to.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.42.54-A-conceptual-illustration-showing-the-advantages-of-automated-testing-for-WordPress-development.-The-image-should-depict-developers-using-automated-to-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.42.54-A-conceptual-illustration-showing-the-advantages-of-automated-testing-for-WordPress-development.-The-image-should-depict-developers-using-automated-to-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.42.54-A-conceptual-illustration-showing-the-advantages-of-automated-testing-for-WordPress-development.-The-image-should-depict-developers-using-automated-to-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.42.54-A-conceptual-illustration-showing-the-advantages-of-automated-testing-for-WordPress-development.-The-image-should-depict-developers-using-automated-to-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.42.54-A-conceptual-illustration-showing-the-advantages-of-automated-testing-for-WordPress-development.-The-image-should-depict-developers-using-automated-to-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>2.WordPress \u958b\u767c\u4e2d\u81ea\u52d5\u5316\u6e2c\u8a66\u548c CI\/CD \u7684\u597d\u8655<\/strong><\/p><ol class=\"wp-block-list\"><li><\/li><\/ol><p>\u81ea\u52d5\u5316\u6e2c\u8a66\u548c\u6301\u7e8c\u6574\u5408\/\u6301\u7e8c\u90e8\u7f72 (CI\/CD) \u5c0d\u7dad\u8b77\u9ad8\u54c1\u8cea\u7684 WordPress \u7db2\u7ad9\u81f3\u95dc\u91cd\u8981\u3002<\/p><ul class=\"wp-block-list\"><li><strong>\u81ea\u52d5\u5316\u6e2c\u8a66<\/strong> \u53ef\u8b93\u958b\u767c\u4eba\u54e1\u53ca\u65e9\u767c\u73fe\u932f\u8aa4\uff0c\u6e1b\u5c11\u5c07\u932f\u8aa4\u90e8\u7f72\u5230\u751f\u7522\u4e2d\u7684\u6a5f\u6703\u3002<\/li>\n\n<li><strong>\u6301\u7e8c\u6574\u5408<\/strong> \u78ba\u4fdd\u4e0d\u540c\u958b\u767c\u4eba\u54e1\u6240\u505a\u7684\u7a0b\u5f0f\u78bc\u8b8a\u66f4\u6703\u5b9a\u671f\u5408\u4f75\u5230\u5171\u7528\u7684\u5132\u5b58\u5eab\u4e2d\uff0c\u6e1b\u5c11\u885d\u7a81\u548c\u6574\u5408\u554f\u984c\u3002<\/li>\n\n<li><strong>\u6301\u7e8c\u90e8\u7f72<\/strong> \u53ef\u81ea\u52d5\u90e8\u7f72\u66f4\u65b0\uff0c\u78ba\u4fdd\u6700\u65b0\u529f\u80fd\u7121\u7e2b\u555f\u7528\uff0c\u800c\u4e0d\u6703\u4e2d\u65b7\u73fe\u6709\u529f\u80fd\u3002<\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.46.26-An-engaging-and-informative-illustration-representing-the-benefits-of-automated-testing-and-CI_CD-in-WordPress-development.-The-image-should-depict-co.webp\" alt=\"\" class=\"wp-image-2361\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.46.26-An-engaging-and-informative-illustration-representing-the-benefits-of-automated-testing-and-CI_CD-in-WordPress-development.-The-image-should-depict-co.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.46.26-An-engaging-and-informative-illustration-representing-the-benefits-of-automated-testing-and-CI_CD-in-WordPress-development.-The-image-should-depict-co-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.46.26-An-engaging-and-informative-illustration-representing-the-benefits-of-automated-testing-and-CI_CD-in-WordPress-development.-The-image-should-depict-co-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.46.26-An-engaging-and-informative-illustration-representing-the-benefits-of-automated-testing-and-CI_CD-in-WordPress-development.-The-image-should-depict-co-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.46.26-An-engaging-and-informative-illustration-representing-the-benefits-of-automated-testing-and-CI_CD-in-WordPress-development.-The-image-should-depict-co-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.46.26-An-engaging-and-informative-illustration-representing-the-benefits-of-automated-testing-and-CI_CD-in-WordPress-development.-The-image-should-depict-co-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>3.WordPress \u81ea\u52d5\u5316\u6e2c\u8a66\u7684\u4e3b\u8981\u5de5\u5177<\/strong><\/p><p>\u6709\u5e7e\u7a2e\u5de5\u5177\u53ef\u4ee5\u7528\u4f86\u7c21\u5316 WordPress \u7684\u81ea\u52d5\u6e2c\u8a66\u3002\u9019\u4e9b\u5de5\u5177\u53ef\u78ba\u4fdd\u4ee3\u78bc\u54c1\u8cea\u3001\u6aa2\u67e5\u5916\u639b\u7a0b\u5f0f\u76f8\u5bb9\u6027\uff0c\u4e26\u5354\u52a9\u5728\u958b\u767c\u9031\u671f\u7684\u65e9\u671f\u627e\u51fa\u554f\u984c\u3002<\/p><p><strong>3.1 PHPUnit<\/strong><\/p><p><strong>PHPUnit<\/strong> \u662f WordPress \u6838\u5fc3\u958b\u767c\u5718\u968a\u8a8d\u53ef\u7684\u5b98\u65b9\u6e2c\u8a66\u6846\u67b6\uff0c\u7528\u65bc\u6e2c\u8a66 PHP \u7a0b\u5f0f\u78bc\u3002\u5b83\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u53ef\u78ba\u4fdd\u5916\u639b\u7a0b\u5f0f\u548c\u4e3b\u984c\u7684\u7a69\u5b9a\u6027\u3002<\/p><p><strong>\u9010\u6b65\u8a2d\u5b9a PHPUnit<\/strong>:<\/p><p><strong>1.\u5b89\u88dd PHPUnit\uff1a<\/strong><\/p><p>\u900f\u904e Composer \u5b89\u88dd PHPUnit\u3002\u57f7\u884c\u4e0b\u5217\u6307\u4ee4\u9032\u884c\u5b89\u88dd\uff1a<\/p><pre class=\"wp-block-code\"><code>composer require --dev phpunit\/phpunit<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:\u4f7f\u7528 Composer \u53ef\u78ba\u4fdd\u60a8\u64c1\u6709\u8207 WordPress \u74b0\u5883\u76f8\u5bb9\u7684\u6b63\u78ba PHPUnit \u7248\u672c\u3002<\/p><p><strong>2.\u514b\u9686 WordPress \u6e2c\u8a66\u8cc7\u6e90\u5eab\uff1a<\/strong><\/p><p>\u514b\u9686 WordPress \u6e2c\u8a66\u5957\u4ef6\u5eab\uff0c\u4ee5\u5efa\u7acb\u9694\u96e2\u7684\u6e2c\u8a66\u74b0\u5883\u3002\u4f7f\u7528 Git \u6216 SVN \u9032\u884c\u8907\u88fd\uff1a<\/p><pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/WordPress\/wordpress-develop.git<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:\u9019\u63d0\u4f9b\u60a8\u6e2c\u8a66 WordPress \u7a0b\u5f0f\u78bc\u6240\u9700\u7684\u6a94\u6848\u548c\u74b0\u5883\uff0c\u800c\u4e0d\u6703\u5f71\u97ff\u60a8\u7684\u751f\u7522\u8a2d\u5b9a\u3002<\/p><figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.56.45-An-instructional-illustration-showing-how-to-set-up-PHPUnit-for-WordPress-development.-The-image-should-include-elements-like-developers-working-on-a-.webp\" alt=\"\" class=\"wp-image-2362\" style=\"width:840px;height:auto\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.56.45-An-instructional-illustration-showing-how-to-set-up-PHPUnit-for-WordPress-development.-The-image-should-include-elements-like-developers-working-on-a-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.56.45-An-instructional-illustration-showing-how-to-set-up-PHPUnit-for-WordPress-development.-The-image-should-include-elements-like-developers-working-on-a--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.56.45-An-instructional-illustration-showing-how-to-set-up-PHPUnit-for-WordPress-development.-The-image-should-include-elements-like-developers-working-on-a--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.56.45-An-instructional-illustration-showing-how-to-set-up-PHPUnit-for-WordPress-development.-The-image-should-include-elements-like-developers-working-on-a--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.56.45-An-instructional-illustration-showing-how-to-set-up-PHPUnit-for-WordPress-development.-The-image-should-include-elements-like-developers-working-on-a--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-17.56.45-An-instructional-illustration-showing-how-to-set-up-PHPUnit-for-WordPress-development.-The-image-should-include-elements-like-developers-working-on-a--768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>3.\u8a2d\u5b9a\u60a8\u7684\u6e2c\u8a66\u74b0\u5883\uff1a<\/strong><\/p><ul class=\"wp-block-list\"><li>\u4f7f\u7528 MAMP\u3001WAMP \u6216 Docker \u7b49\u672c\u6a5f\u4f3a\u670d\u5668\u5efa\u7acb\u672c\u6a5f\u6e2c\u8a66\u74b0\u5883\u3002\u9019\u4e00\u6b65\u9a5f\u53ef\u78ba\u4fdd\u6e2c\u8a66\u74b0\u5883\u76e1\u53ef\u80fd\u8207\u60a8\u7684\u751f\u7522\u74b0\u5883\u76f8\u5339\u914d\u3002<\/li>\n\n<li><strong>\u63d0\u793a<\/strong>:Docker \u5c0d\u65bc\u5efa\u7acb\u9694\u96e2\u7684\u5bb9\u5668\u7279\u5225\u6709\u7528\uff0c\u53ef\u4ee5\u9632\u6b62\u8207\u60a8\u7684\u4e3b\u8981\u958b\u767c\u8a2d\u5b9a\u885d\u7a81\u3002<\/li><\/ul><p><strong>4.\u57f7\u884c PHPUnit \u6e2c\u8a66\uff1a<\/strong><\/p><p>\u4f7f\u7528\u4e0b\u5217\u6307\u4ee4\u57f7\u884c\u6e2c\u8a66\uff1a<\/p><pre class=\"wp-block-code\"><code>.\/vendor\/bin\/phpunit<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:\u57f7\u884c\u6e2c\u8a66\u6709\u52a9\u65bc\u5728\u958b\u767c\u904e\u7a0b\u4e2d\u53ca\u65e9\u767c\u73fe\u932f\u8aa4\uff0c\u63d0\u9ad8\u7a0b\u5f0f\u78bc\u54c1\u8cea\u4e26\u6e1b\u5c11\u90e8\u7f72\u554f\u984c\u3002<\/p><p><strong>PHPUnit<\/strong> \u662f\u6e2c\u8a66\u5916\u639b\u7a0b\u5f0f\u548c\u4e3b\u984c\u5f8c\u7aef\u529f\u80fd\u7684\u7406\u60f3\u9078\u64c7\uff0c\u53ef\u70ba\u958b\u767c\u4eba\u54e1\u63d0\u4f9b\u8a73\u7d30\u7684\u56de\u994b\u3002<\/p><p><strong>3.2 WP-CLI<\/strong><\/p><p><strong>WP-CLI<\/strong> \u662f WordPress \u7684\u547d\u4ee4\u5217\u4ecb\u9762\uff0c\u53ef\u7c21\u5316 PHPUnit \u6e2c\u8a66\u7684\u8a2d\u5b9a\u8207\u7ba1\u7406\u3002<\/p><p><strong>\u4f7f\u7528 WP-CLI \u8a2d\u5b9a\u6e2c\u8a66<\/strong>:<\/p><p><strong>1.\u5b89\u88dd WP-CLI\uff1a<\/strong><\/p><ul class=\"wp-block-list\"><li>\u4f7f\u7528\u547d\u4ee4\u5217\u4e0b\u8f09 WP-CLI\uff1a<\/li><\/ul><pre class=\"wp-block-code\"><code>curl -O https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar\nchmod +x wp-cli.phar\nmv wp-cli.phar \/usr\/local\/bin\/wp<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:WP-CLI \u63d0\u4f9b\u66f4\u5feb\u7684\u65b9\u5f0f\u4f86\u7ba1\u7406 WordPress \u5b89\u88dd\uff0c\u7279\u5225\u662f\u5c0d\u65bc\u91cd\u8907\u6027\u7684\u5de5\u4f5c\uff0c\u4f8b\u5982\u8a2d\u5b9a\u6e2c\u8a66\u74b0\u5883\uff0c\u975e\u5e38\u6709\u7528\u3002<\/p><p><strong>2.\u7522\u751f\u5916\u639b\u7a0b\u5f0f\u6e2c\u8a66\u6a94\uff1a<\/strong><\/p><p><strong>\u4f7f\u7528 WP-CLI \u70ba\u60a8\u7684\u5916\u639b\u7a0b\u5f0f\u5efa\u7acb\u55ae\u5143\u6e2c\u8a66\u6a94\u6848\uff1a<\/strong><\/p><pre class=\"wp-block-code\"><code>wp scaffold plugin-tests my-plugin<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:\u64a0 <code>wp scaffold \u5916\u639b\u7a0b\u5f0f\u6e2c\u8a66<\/code> \u6307\u4ee4\u6703\u5efa\u7acb\u958b\u59cb\u6e2c\u8a66\u6240\u9700\u7684\u6240\u6709\u6a94\u6848\uff0c\u7bc0\u7701\u60a8\u7684\u6642\u9593\u3002<\/p><p><strong>3.\u8a2d\u5b9a\u6e2c\u8a66\u8cc7\u6599\u5eab\uff1a<\/strong><\/p><p>\u5efa\u7acb\u7368\u7acb\u7684\u6e2c\u8a66\u8cc7\u6599\u5eab\u4f86\u57f7\u884c\u55ae\u5143\u6e2c\u8a66\uff0c\u800c\u4e0d\u6703\u5f71\u97ff\u60a8\u7684\u751f\u7522\u8cc7\u6599\uff1a<\/p><pre class=\"wp-block-code\"><code>bash bin\/install-wp-tests.sh wordpress_test root '' localhost<\/code><\/pre><p><strong>\u63d0\u793a<\/strong>:\u8acb\u52d9\u5fc5\u4f7f\u7528\u5c08\u7528\u7684\u6e2c\u8a66\u8cc7\u6599\u5eab\uff0c\u4ee5\u9632\u6b62\u610f\u5916\u4fee\u6539\u60a8\u7684\u5373\u6642\u7db2\u7ad9\u8cc7\u6599\u3002<\/p><p><strong>4.\u57f7\u884c\u6e2c\u8a66\uff1a<\/strong><\/p><ul class=\"wp-block-list\"><li>\u4f7f\u7528 PHPUnit \u64b0\u5beb\u55ae\u5143\u6e2c\u8a66\u4e26\u57f7\u884c\u5b83\u5011\u3002WP-CLI \u6709\u52a9\u65bc\u81ea\u52d5\u5316\u8173\u624b\u67b6\u904e\u7a0b\uff0c\u4f7f\u958b\u59cb\u6e2c\u8a66\u8b8a\u5f97\u66f4\u7c21\u55ae\u3002<\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.06.48-An-instructional-illustration-showing-developers-using-WP-CLI-and-PHPUnit-for-testing-WordPress-plugins-and-themes.-Include-visuals-of-developers-work.webp\" alt=\"\" class=\"wp-image-2363\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.06.48-An-instructional-illustration-showing-developers-using-WP-CLI-and-PHPUnit-for-testing-WordPress-plugins-and-themes.-Include-visuals-of-developers-work.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.06.48-An-instructional-illustration-showing-developers-using-WP-CLI-and-PHPUnit-for-testing-WordPress-plugins-and-themes.-Include-visuals-of-developers-work-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.06.48-An-instructional-illustration-showing-developers-using-WP-CLI-and-PHPUnit-for-testing-WordPress-plugins-and-themes.-Include-visuals-of-developers-work-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.06.48-An-instructional-illustration-showing-developers-using-WP-CLI-and-PHPUnit-for-testing-WordPress-plugins-and-themes.-Include-visuals-of-developers-work-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.06.48-An-instructional-illustration-showing-developers-using-WP-CLI-and-PHPUnit-for-testing-WordPress-plugins-and-themes.-Include-visuals-of-developers-work-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.06.48-An-instructional-illustration-showing-developers-using-WP-CLI-and-PHPUnit-for-testing-WordPress-plugins-and-themes.-Include-visuals-of-developers-work-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>3.3 \u7528\u65bc\u7aef\u5c0d\u7aef\u6e2c\u8a66\u7684 Cypress<\/strong><\/p><p><strong>\u8cfd\u666e\u62c9\u65af<\/strong> \u662f\u4e00\u500b\u958b\u653e\u539f\u59cb\u78bc\u6846\u67b6\uff0c\u7528\u4f86\u70ba WordPress \u7db2\u7ad9\u5efa\u7acb\u7aef\u5c0d\u7aef\u6e2c\u8a66\u3002\u5b83\u5c0d\u65bc\u6e2c\u8a66\u7db2\u7ad9\u5982\u4f55\u8207\u4f7f\u7528\u8005\u4e92\u52d5\u7279\u5225\u6709\u7528\u3002<\/p><p><strong>\u5982\u4f55\u8a2d\u5b9a Cypress<\/strong>:<\/p><p><strong>1.\u5b89\u88dd Cypress\uff1a<\/strong><\/p><p>\u900f\u904e npm \u5b89\u88dd Cypress\uff1a<\/p><pre class=\"wp-block-code\"><code>npm install cypress --save-dev<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:Cypress \u5c08\u70ba\u7aef\u5c0d\u7aef\u6e2c\u8a66\u800c\u8a2d\u8a08\uff0c\u9019\u8868\u793a\u5b83\u80fd\u6e2c\u8a66\u60a8\u7db2\u7ad9\u7684\u6574\u500b\u5de5\u4f5c\u6d41\u7a0b\uff0c\u63d0\u4f9b\u4f7f\u7528\u8005\u4e92\u52d5\u7684\u6df1\u5165\u77ad\u89e3\u3002<\/p><p><strong>2.\u8a2d\u5b9a Cypress\uff1a<\/strong><\/p><p>Cypress \u6703\u81ea\u52d5\u5efa\u7acb\u5fc5\u8981\u7684\u6a94\u6848\u548c\u8cc7\u6599\u593e\uff0c\u4f8b\u5982 <code>cypress.json<\/code>\uff0c\u4f86\u8a2d\u5b9a\u6846\u67b6\u3002\u60a8\u53ef\u4ee5\u6839\u64da\u5c08\u6848\u9700\u6c42\u8a2d\u5b9a\u6b64\u6a94\u6848\u3002<\/p><p><strong>\u63d0\u793a<\/strong>:\u81ea\u8a02 <code>baseUrl<\/code> \u65bc <code>cypress.json<\/code> \u4ee5\u7b26\u5408\u60a8\u7684\u6e2c\u8a66\u74b0\u5883\u3002<\/p><p><strong>3.Write Tests\uff1a<\/strong><\/p><p>Cypress \u4f7f\u7528 JavaScript \u4f86\u64b0\u5beb\u6e2c\u8a66\u8173\u672c\u3002\u4f8b\u5982\uff0c\u6e2c\u8a66\u767b\u5165\u9801\u9762\uff1a<\/p><pre class=\"wp-block-code\"><code>describe('Login Test', () =&gt; {\n  it('should log in successfully', () =&gt; {\n    cy.visit('https:\/\/example.com\/login')\uff1b\n    cy.get('input[name=\"username\"]').type('user')\uff1b\n    cy.get('input[name=\"password\"]').type('password')\uff1b\n    cy.get('button[type=\"submit\"]').click()\uff1b\n    cy.contains('Dashboard').should('be.visible')\uff1b\n  });\n});<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:Cypress \u63d0\u4f9b\u4e86\u6e05\u6670\u7684\u8a9e\u6cd5\uff0c\u5373\u4f7f\u662f\u521d\u5b78\u8005\u4e5f\u80fd\u8f15\u9b06\u64b0\u5beb\u548c\u7406\u89e3\u6e2c\u8a66\u6848\u4f8b\u3002<\/p><p><strong>4.\u57f7\u884c\u6e2c\u8a66\uff1a<\/strong><\/p><p>\u4f7f\u7528 Cypress \u57f7\u884c\u6e2c\u8a66\uff1a<\/p><pre class=\"wp-block-code\"><code>npx \u6a9c\u6728\u958b\u53e3<\/code><\/pre><p><strong>\u63d0\u793a<\/strong>:Cypress UI \u4ee5\u8996\u89ba\u5316\u7684\u65b9\u5f0f\u5448\u73fe\u6bcf\u500b\u6e2c\u8a66\u6b65\u9a5f\uff0c\u8b93\u9664\u932f\u66f4\u52a0\u5bb9\u6613\u3002<\/p><p><strong>\u8cfd\u666e\u62c9\u65af<\/strong> \u63d0\u4f9b\u9ad8\u5ea6\u8996\u89ba\u5316\u3001\u4e92\u52d5\u5f0f\u7684\u4f7f\u7528\u8005\u4e92\u52d5\u6e2c\u8a66\u65b9\u5f0f\uff0c\u5c0d\u524d\u7aef\u6e2c\u8a66\u7279\u5225\u6709\u6548\u3002<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.15.35-An-instructional-illustration-depicting-developers-setting-up-Cypress-for-end-to-end-testing-of-WordPress-websites.-Include-visuals-of-a-developer-usi.webp\" alt=\"\" class=\"wp-image-2364\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.15.35-An-instructional-illustration-depicting-developers-setting-up-Cypress-for-end-to-end-testing-of-WordPress-websites.-Include-visuals-of-a-developer-usi.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.15.35-An-instructional-illustration-depicting-developers-setting-up-Cypress-for-end-to-end-testing-of-WordPress-websites.-Include-visuals-of-a-developer-usi-600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.15.35-An-instructional-illustration-depicting-developers-setting-up-Cypress-for-end-to-end-testing-of-WordPress-websites.-Include-visuals-of-a-developer-usi-100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.15.35-An-instructional-illustration-depicting-developers-setting-up-Cypress-for-end-to-end-testing-of-WordPress-websites.-Include-visuals-of-a-developer-usi-300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.15.35-An-instructional-illustration-depicting-developers-setting-up-Cypress-for-end-to-end-testing-of-WordPress-websites.-Include-visuals-of-a-developer-usi-150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.15.35-An-instructional-illustration-depicting-developers-setting-up-Cypress-for-end-to-end-testing-of-WordPress-websites.-Include-visuals-of-a-developer-usi-768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><p><strong>3.4 Behat \u7528\u65bc\u884c\u70ba\u9a45\u52d5\u958b\u767c (BDD)<\/strong><\/p><p><strong>\u8c9d\u54c8\u7279<\/strong> \u662f\u4e00\u500b\u5c08\u6ce8\u65bc\u884c\u70ba\u9a45\u52d5\u958b\u767c (BDD) \u7684\u6846\u67b6\uff0c\u975e\u5e38\u9069\u5408\u5728 WordPress \u6e2c\u8a66\u4f7f\u7528\u8005\u9ad4\u9a57\u3002<\/p><p><strong>\u8a2d\u5b9a Behat<\/strong>:<\/p><p><strong>1.\u5b89\u88dd Behat\uff1a<\/strong><\/p><p>\u4f7f\u7528 Composer \u5b89\u88dd Behat\uff1a<\/p><pre class=\"wp-block-code\"><code>composer require --dev behat\/behat<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:Behat \u53ef\u8b93\u60a8\u4ee5\u81ea\u7136\u8a9e\u8a00\u6e2c\u8a66 WordPress \u61c9\u7528\u7a0b\u5f0f\u7684\u884c\u70ba\uff0c\u78ba\u4fdd\u529f\u80fd\u7b26\u5408\u696d\u52d9\u9700\u6c42\u3002<\/p><p><strong>2.\u8a2d\u5b9a Behat\uff1a<\/strong><\/p><p>\u5efa\u7acb\u4e00\u500b <code>behat.yml<\/code> \u914d\u7f6e\u6a94\u6848\uff1a<\/p><pre class=\"wp-block-code\"><code>\u9810\u8a2d\uff1a\n  suites\uff1a\n    default\uff1a\n      contexts\uff1a\n        - FeatureContext\n  extensions\uff1a\n    Behat\\MinkExtension\uff1a\n      base_url: http:\/\/localhost\n      selenium2: ~<\/code><\/pre><p><strong>\u63d0\u793a<\/strong>:\u4f7f\u7528 MinkExtension \u9032\u884c\u700f\u89bd\u5668\u81ea\u52d5\u5316\uff0c\u8b93\u6a21\u64ec\u4f7f\u7528\u8005\u4e92\u52d5\u8b8a\u5f97\u66f4\u5bb9\u6613\u3002<\/p><p><strong>3.Write Scenarios in Gherkin\uff1a<\/strong><\/p><p>Behat \u4f7f\u7528 Gherkin\uff0c\u9019\u662f\u4e00\u7a2e\u63cf\u8ff0\u4f7f\u7528\u8005\u884c\u70ba\u7684\u8a9e\u8a00\u3002\u8209\u4f8b\u4f86\u8aaa<\/p><pre class=\"wp-block-code\"><code>\u529f\u80fd\uff1a\u4f7f\u7528\u8005\u767b\u5165\n  \u60c5\u666f\uff1a\u6210\u529f\u767b\u5165\n    \u6211\u5728 \"\/login\" \u4e0a\n    \u7576\u6211\u586b\u5165 \u300c\u4f7f\u7528\u8005\u540d\u7a31\u300d \u70ba \"user\" \u6642\n    \u6211\u586b\u5165 \u300c\u5bc6\u78bc \u300d\u70ba \"password\n    \u7136\u5f8c\u6309\u300c\u767b\u5165\n    \u7136\u5f8c\u6211\u61c9\u8a72\u6703\u770b\u5230\u300c\u6b61\u8fce\u4f86\u5230\u60a8\u7684\u5100\u8868\u677f\u300d\u3002<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:\u4ee5 Gherkin \u8a9e\u8a00\u64b0\u5beb\u53ef\u8b93\u975e\u6280\u8853\u5229\u5bb3\u95dc\u4fc2\u4eba\u77ad\u89e3\u6e2c\u8a66\u7684\u5167\u5bb9\u3002<\/p><p><strong>4.\u57f7\u884c\u6e2c\u8a66\uff1a<\/strong><\/p><p>\u4f7f\u7528 Behat \u57f7\u884c\uff1a<\/p><pre class=\"wp-block-code\"><code>\u4f9b\u61c9\u5546\/bin\/behat<\/code><\/pre><p><strong>\u63d0\u793a<\/strong>:\u7d93\u5e38\u57f7\u884c\u6e2c\u8a66\u6709\u52a9\u65bc\u627e\u51fa\u9810\u671f\u8207\u5be6\u969b\u884c\u70ba\u4e4b\u9593\u7684\u5dee\u7570\u3002<\/p><p><strong>\u8c9d\u54c8\u7279<\/strong> \u662f\u78ba\u4fdd\u60a8\u7684 WordPress \u7db2\u7ad9\u7b26\u5408\u696d\u52d9\u9700\u6c42\u7684\u7406\u60f3\u9078\u64c7\uff0c\u5b83\u8457\u91cd\u65bc\u7d42\u7aef\u4f7f\u7528\u8005\u7684\u4f7f\u7528\u60c5\u5883\u3002<\/p><p><strong>3.5 \u5168\u9762\u6e2c\u8a66\u7684\u5b88\u5247\u6982\u5ff5<\/strong><\/p><p><strong>\u9a57\u8b49\u78bc<\/strong> \u8b93\u958b\u767c\u4eba\u54e1\u53ef\u4ee5\u5728\u55ae\u4e00\u5de5\u5177\u4e2d\u9032\u884c\u55ae\u5143\u3001\u529f\u80fd\u548c\u9a57\u6536\u6e2c\u8a66\uff0c\u70ba WordPress \u5c08\u6848\u63d0\u4f9b\u5168\u9762\u7684\u6e2c\u8a66\u3002<\/p><p><strong>\u5982\u4f55\u8a2d\u5b9a Codeception<\/strong>:<\/p><p><strong>1.\u5b89\u88dd Codeception\uff1a<\/strong><\/p><p>\u4f7f\u7528 Composer \u5b89\u88dd Codeception\uff1a<\/p><pre class=\"wp-block-code\"><code>composer require codeception\/codeception --dev<\/code><\/pre><p><strong>\u539f\u56e0<\/strong>:Codeception \u652f\u63f4\u4e0d\u540c\u7684\u6e2c\u8a66\uff0c\u4f7f\u5176\u6210\u70ba\u5168\u9762\u6027 WordPress \u6e2c\u8a66\u7684\u901a\u7528\u5de5\u5177\u3002<\/p><p><strong>2.\u521d\u59cb\u5316 Codeception\uff1a<\/strong><\/p><p>\u57f7\u884c\u521d\u59cb\u5316\u6307\u4ee4\u4ee5\u8a2d\u5b9a Codeception\uff1a<\/p><pre class=\"wp-block-code\"><code>vendor\/bin\/codecept bootstrap<\/code><\/pre><p><strong>\u63d0\u793a<\/strong>:\u521d\u59cb\u5316 Codeception \u6703\u70ba\u4e0d\u540c\u7684\u6e2c\u8a66\u5957\u4ef6\u5efa\u7acb\u6240\u9700\u7684\u8cc7\u6599\u593e\u7d50\u69cb\u3002<\/p><p><strong>3.\u8a2d\u5b9a\u6e2c\u8a66\u5957\u4ef6\uff1a<\/strong><\/p><ul class=\"wp-block-list\"><li>\u81ea\u8a02 codeception.yml \u6a94\u6848\uff0c\u4e26\u8a2d\u5b9a\u7279\u5b9a\u5957\u4ef6\uff0c\u4f8b\u5982\u9a57\u6536\u6216\u55ae\u5143\u6e2c\u8a66\u3002<\/li>\n\n<li><strong>\u539f\u56e0<\/strong>:\u6bcf\u500b\u5957\u4ef6\u90fd\u6709\u5176\u7368\u7279\u7684\u76ee\u7684\uff0c\u53ef\u9032\u884c\u6709\u91dd\u5c0d\u6027\u7684\u6e2c\u8a66\u3002<\/li><\/ul><p><strong>4.Write Tests\uff1a<\/strong><\/p><p>Codeception \u652f\u63f4\u4ee5 PHP \u70ba\u57fa\u790e\u7684\u6e2c\u8a66\u8173\u672c\uff0c\u4ee5\u6e2c\u8a66\u4e0d\u540c\u7684\u60c5\u5883\uff0c\u4f8b\u5982\uff1a<\/p><pre class=\"wp-block-code\"><code>wantTo('ensure that login works')\uff1b\n$I-&gt;amOnPage('\/login')\uff1b\n$I-&gt;fillField('username', 'user')\uff1b\n$I-&gt;fillField('password', 'password')\uff1b\n$I-&gt;click('Login')\uff1b\n$I-&gt;see('Dashboard')\uff1b<\/code><\/pre><p><strong>\u63d0\u793a<\/strong>:\u4f7f\u7528\u63cf\u8ff0\u6027\u7684\u6e2c\u8a66\u540d\u7a31\u53ef\u4ee5\u8b93\u60a8\u66f4\u5bb9\u6613\u4e86\u89e3\u6e2c\u8a66\u7684\u610f\u5716\u548c\u7d50\u679c\u3002<\/p><p><strong>5.\u57f7\u884c\u6e2c\u8a66\uff1a<\/strong><\/p><ul class=\"wp-block-list\"><li>\u4f7f\u7528 \u6307\u4ee4\u57f7\u884c\u6e2c\u8a66\uff1a<\/li><\/ul><pre class=\"wp-block-code\"><code>vendor\/bin\/codecept run<\/code><\/pre><p><strong>\u9a57\u8b49\u78bc<\/strong> \u5c07\u4e0d\u540c\u7684\u6e2c\u8a66\u7d50\u5408\u5230\u55ae\u4e00\u5de5\u4f5c\u6d41\u7a0b\u4e2d\uff0c\u5f37\u5927\u9a57\u8b49\u8907\u96dc\u7684 WordPress \u5c08\u6848\u3002<\/p><p><strong>4.\u6e2c\u8a66\u5de5\u5177\u8207\u958b\u767c\u74b0\u5883\u7684\u6574\u5408<\/strong><\/p><p>\u5c07\u81ea\u52d5\u6e2c\u8a66\u5de5\u5177\u8207\u958b\u767c\u74b0\u5883\u6574\u5408\uff0c\u6709\u52a9\u65bc\u7c21\u5316\u548c\u5f37\u5316\u6e2c\u8a66\u6d41\u7a0b\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5c07\u9019\u4e9b\u5de5\u5177\u6574\u5408\u5230\u4e0d\u540c\u7684\u74b0\u5883\u4e2d\uff1a<\/p><ul class=\"wp-block-list\"><li><strong>Docker<\/strong>:\u4f7f\u7528 Docker \u5efa\u7acb\u7368\u7acb\u7684\u5bb9\u5668\uff0c\u93e1\u5c04\u60a8\u7684\u751f\u7522\u74b0\u5883\uff0c\u78ba\u4fdd\u60a8\u7684\u6e2c\u8a66\u5728\u4e0d\u540c\u74b0\u5883\u4e2d\u4fdd\u6301\u4e00\u81f4\u3002<ul class=\"wp-block-list\"><li><strong>\u63d0\u793a<\/strong>:Docker \u53ef\u8b93\u60a8\u5728\u8207\u751f\u7522\u74b0\u5883\u5b8c\u5168\u76f8\u540c\u7684\u74b0\u5883\u4e2d\u57f7\u884c\u6e2c\u8a66\uff0c\u5c07\u300c\u5b83\u5728\u6211\u7684\u6a5f\u5668\u4e0a\u53ef\u4ee5\u904b\u4f5c\u300d\u7684\u554f\u984c\u6e1b\u5230\u6700\u4f4e\u3002<\/li><\/ul><\/li>\n\n<li><strong>DevKinsta<\/strong>:DevKinsta \u63d0\u4f9b\u5b8c\u6574\u7684\u672c\u6a5f WordPress \u958b\u767c\u74b0\u5883\uff0c\u53ef\u8f15\u9b06\u6574\u5408 PHPUnit \u548c Behat \u7b49\u5de5\u5177\u3002<ul class=\"wp-block-list\"><li><strong>\u63d0\u793a<\/strong>:\u4f7f\u7528 DevKinsta \u5728\u672c\u6a5f\u9032\u884c\u6e2c\u8a66\uff0c\u4e26\u5728\u90e8\u7f72\u8b8a\u66f4\u4e4b\u524d\u627e\u51fa\u554f\u984c\u3002<\/li><\/ul><\/li>\n\n<li><strong>MAMP\/WAMP<\/strong>:MAMP \u548c WAMP \u5275\u5efa\u672c\u5730\u74b0\u5883<\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.32.20-An-illustration-showing-the-integration-of-automated-testing-tools-with-development-environments-like-Docker-DevKinsta-and-MAMP_WAMP-for-WordPress.-.webp\" alt=\"\" class=\"wp-image-2368\" srcset=\"https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.32.20-An-illustration-showing-the-integration-of-automated-testing-tools-with-development-environments-like-Docker-DevKinsta-and-MAMP_WAMP-for-WordPress.-.webp 1024w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.32.20-An-illustration-showing-the-integration-of-automated-testing-tools-with-development-environments-like-Docker-DevKinsta-and-MAMP_WAMP-for-WordPress.--600x600.webp 600w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.32.20-An-illustration-showing-the-integration-of-automated-testing-tools-with-development-environments-like-Docker-DevKinsta-and-MAMP_WAMP-for-WordPress.--100x100.webp 100w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.32.20-An-illustration-showing-the-integration-of-automated-testing-tools-with-development-environments-like-Docker-DevKinsta-and-MAMP_WAMP-for-WordPress.--300x300.webp 300w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.32.20-An-illustration-showing-the-integration-of-automated-testing-tools-with-development-environments-like-Docker-DevKinsta-and-MAMP_WAMP-for-WordPress.--150x150.webp 150w, https:\/\/www.openbyt.com\/wp-content\/uploads\/2024\/10\/DALL\u00b7E-2024-10-11-18.32.20-An-illustration-showing-the-integration-of-automated-testing-tools-with-development-environments-like-Docker-DevKinsta-and-MAMP_WAMP-for-WordPress.--768x768.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>","protected":false},"excerpt":{"rendered":"<p>\u8edf\u9ad4\u958b\u767c\uff08\u5305\u62ec WordPress\uff09\u5b8c\u5168\u4f9d\u8cf4\u624b\u52d5\u6e2c\u8a66\u7684\u6642\u4ee3\u5df2\u7d93\u7d50\u675f\u3002\u5f9e\u624b\u52d5\u6e2c\u8a66\u904e\u6e21\u5230\u81ea\u52d5\u5316\u6e2c\u8a66\uff0c\u662f...<\/p>","protected":false},"author":1,"featured_media":3095,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36,83],"tags":[207,209,208,210,206],"class_list":["post-2348","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev-tips","category-developer-tips","tag-automated-testing","tag-continuous-deployment-cd","tag-continuous-integration-ci","tag-phpunit","tag-wordpress-development",""],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts\/2348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/comments?post=2348"}],"version-history":[{"count":8,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts\/2348\/revisions"}],"predecessor-version":[{"id":3193,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/posts\/2348\/revisions\/3193"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/media\/3095"}],"wp:attachment":[{"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/media?parent=2348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/categories?post=2348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.openbyt.com\/zh\/wp-json\/wp\/v2\/tags?post=2348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}