{"id":39422,"date":"2025-05-23T18:13:09","date_gmt":"2025-05-23T10:13:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/39422.html"},"modified":"2025-05-23T18:13:09","modified_gmt":"2025-05-23T10:13:09","slug":"junit%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/39422.html","title":{"rendered":"junit\u5355\u5143\u6d4b\u8bd5"},"content":{"rendered":"<p>\u00a0\u5355\u5143\u6d4b\u8bd5<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1124\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101300-68304a2c11173.png\" width=\"2123\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"808\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101301-68304a2d61b55.png\" width=\"2070\" \/><\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"146\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101302-68304a2e3aa4c.png\" width=\"1253\" \/><\/p>\n<\/p>\n<p>\u5355\u5143\u6d4b\u8bd5<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"269\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101302-68304a2e5cc1a.png\" width=\"1769\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"814\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101302-68304a2e95beb.png\" width=\"1698\" \/><\/p>\n<p>\u7528main\u65b9\u6cd5\u6d4b\u8bd5&#xff0c;\u5982\u679c\u4e00\u4e2a\u65b9\u6cd5\u62a5\u9519&#xff0c;\u5176\u4ed6\u5168\u90e8\u90fd\u4e0d\u80fd\u8fdb\u884c\u6d4b\u8bd5\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"745\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101303-68304a2f3bf16.png\" width=\"695\" \/><\/p>\n<\/p>\n<p>\u5f15\u7528junit<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"722\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101303-68304a2f59e9e.png\" width=\"1437\" \/><\/p>\n<p>\u4e3b\u7a0b\u5e8f\u4ee3\u7801<\/p>\n<p>package com.itheima;<\/p>\n<p>import java.time.LocalDate;<br \/>\nimport java.time.Period;<br \/>\nimport java.time.format.DateTimeFormatter;<\/p>\n<p>public class UserService {<\/p>\n<p>    \/**<br \/>\n     * \u7ed9\u5b9a\u4e00\u4e2a\u8eab\u4efd\u8bc1\u53f7, \u8ba1\u7b97\u51fa\u8be5\u7528\u6237\u7684\u5e74\u9f84<br \/>\n     * &#064;param idCard \u8eab\u4efd\u8bc1\u53f7<br \/>\n     *\/<br \/>\n    public Integer getAge(String idCard){<br \/>\n        if (idCard &#061;&#061; null || idCard.length() !&#061; 18) {<br \/>\n            throw new IllegalArgumentException(&#034;\u65e0\u6548\u7684\u8eab\u4efd\u8bc1\u53f7\u7801&#034;);<br \/>\n        }<br \/>\n        String birthday &#061; idCard.substring(6, 14);<br \/>\n        LocalDate parse &#061; LocalDate.parse(birthday, DateTimeFormatter.ofPattern(&#034;yyyyMMdd&#034;));<br \/>\n        return Period.between(parse, LocalDate.now()).getYears();<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u7ed9\u5b9a\u4e00\u4e2a\u8eab\u4efd\u8bc1\u53f7, \u8ba1\u7b97\u51fa\u8be5\u7528\u6237\u7684\u6027\u522b<br \/>\n     * &#064;param idCard \u8eab\u4efd\u8bc1\u53f7<br \/>\n     *\/<br \/>\n    public String getGender(String idCard){<br \/>\n        if (idCard &#061;&#061; null || idCard.length() !&#061; 18) {<br \/>\n            throw new IllegalArgumentException(&#034;\u65e0\u6548\u7684\u8eab\u4efd\u8bc1\u53f7\u7801&#034;);<br \/>\n        }<br \/>\n        return Integer.parseInt(idCard.substring(16,17)) % 2 &#061;&#061; 1 ? &#034;\u7537&#034; : &#034;\u5973&#034;;<br \/>\n    }<\/p>\n<p>}<\/p>\n<p>\u6d4b\u8bd5\u4ee3\u7801<\/p>\n<p>package com.itheima;<\/p>\n<p>import org.junit.jupiter.api.*;<br \/>\nimport org.junit.jupiter.params.ParameterizedTest;<br \/>\nimport org.junit.jupiter.params.provider.ValueSource;<\/p>\n<p>\/**<br \/>\n * \u6d4b\u8bd5\u7c7b<br \/>\n *\/<br \/>\n&#064;DisplayName(&#034;\u7528\u6237\u4fe1\u606f\u6d4b\u8bd5\u7c7b&#034;)<br \/>\npublic class UserServiceTest {<\/p>\n<p>    \/*&#064;BeforeAll \/\/\u5728\u6240\u6709\u7684\u5355\u5143\u6d4b\u8bd5\u65b9\u6cd5\u8fd0\u884c\u4e4b\u524d, \u8fd0\u884c\u4e00\u6b21<br \/>\n    public static void beforeAll(){<br \/>\n        System.out.println(&#034;before All&#034;);<br \/>\n    }<br \/>\n    &#064;AfterAll \/\/\u5728\u6240\u6709\u7684\u5355\u5143\u6d4b\u8bd5\u65b9\u6cd5\u8fd0\u884c\u4e4b\u540e, \u8fd0\u884c\u4e00\u6b21<br \/>\n    public static void afterAll(){<br \/>\n        System.out.println(&#034;after All&#034;);<br \/>\n    }<br \/>\n    &#064;BeforeEach \/\/\u5728\u6bcf\u4e00\u4e2a\u5355\u5143\u6d4b\u8bd5\u65b9\u6cd5\u8fd0\u884c\u4e4b\u524d, \u90fd\u4f1a\u8fd0\u884c\u4e00\u6b21<br \/>\n    public void beforeEach(){<br \/>\n        System.out.println(&#034;before Each&#034;);<br \/>\n    }<br \/>\n    &#064;AfterEach \/\/\u5728\u6bcf\u4e00\u4e2a\u5355\u5143\u6d4b\u8bd5\u65b9\u6cd5\u8fd0\u884c\u4e4b\u540e, \u90fd\u4f1a\u8fd0\u884c\u4e00\u6b21<br \/>\n    public void afterEach(){<br \/>\n        System.out.println(&#034;after Each&#034;);<br \/>\n    }*\/<\/p>\n<p>    &#064;Test<br \/>\n    public void testGetAge(){<br \/>\n        UserService userService &#061; new UserService();<br \/>\n        Integer age &#061; userService.getAge(&#034;100000200010011011&#034;);<br \/>\n        System.out.println(age);<br \/>\n    }<\/p>\n<p>    &#064;Test<br \/>\n    public void testGetGender(){<br \/>\n        UserService userService &#061; new UserService();<br \/>\n        String gender &#061; userService.getGender(&#034;100000200010011011&#034;);<br \/>\n        System.out.println(gender);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u65ad\u8a00<br \/>\n     *\/<br \/>\n    &#064;Test<br \/>\n    public void testGenderWithAssert(){<br \/>\n        UserService userService &#061; new UserService();<br \/>\n        String gender &#061; userService.getGender(&#034;100000200010011011&#034;);<br \/>\n        \/\/\u65ad\u8a00<br \/>\n        \/\/Assertions.assertEquals(&#034;\u7537&#034;, gender);<br \/>\n        Assertions.assertEquals(&#034;\u7537&#034;, gender, &#034;\u6027\u522b\u83b7\u53d6\u9519\u8bef\u6709\u95ee\u9898&#034;);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u65ad\u8a00<br \/>\n     *\/<br \/>\n    &#064;Test<br \/>\n    public void testGenderWithAssert2(){<br \/>\n        UserService userService &#061; new UserService();<br \/>\n        \/\/\u65ad\u8a00<br \/>\n        Assertions.assertThrows(IllegalArgumentException.class, () -&gt; {<br \/>\n            userService.getGender(null);<br \/>\n        });<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u53c2\u6570\u5316\u6d4b\u8bd5<br \/>\n     *\/<br \/>\n    &#064;DisplayName(&#034;\u6d4b\u8bd5\u7528\u6237\u6027\u522b&#034;)<br \/>\n    &#064;ParameterizedTest<br \/>\n    &#064;ValueSource(strings &#061; {&#034;100000200010011011&#034;,&#034;100000200010011031&#034;,&#034;100000200010011051&#034;})<br \/>\n    public void testGetGender2(String idCard){<br \/>\n        UserService userService &#061; new UserService();<br \/>\n        String gender &#061; userService.getGender(idCard);<br \/>\n        \/\/\u65ad\u8a00<br \/>\n        Assertions.assertEquals(&#034;\u7537&#034;, gender);<br \/>\n    }<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"761\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101303-68304a2fa9694.png\" width=\"976\" \/><\/p>\n<p>\u89c4\u5b9a\u5fc5\u987b\u6267\u884c&#xff0c;\u89c4\u8303\u4e0d\u662f<\/p>\n<\/p>\n<p>\u8eab\u4efd\u8bc1\u5012\u6570\u7b2c\u4e8c\u4f4d\u4e3a\u5947\u6570&#xff1a;\u7537\u6027\u00a0 \u5076\u6570&#xff1a;\u5973\u6027<\/p>\n<p>\u6ce8\u610f&#xff1a;\u5e76\u4e0d\u662f\u8bf4\u8fd0\u884c\u5230\u662f\u7eff\u8272\u5c31\u8bf4\u660e\u4ee3\u7801\u6ca1\u9519\u3002\u60f3\u8981\u5224\u65ad\u903b\u8f91\u6709\u6ca1\u6709\u9519\u8bef\u9700\u8981\u7528\u5230\u65ad\u8a00<\/p>\n<\/p>\n<p>\u65ad\u8a00<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"828\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101303-68304a2fe2e54.png\" width=\"1992\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"72\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101304-68304a3093aa3.png\" width=\"1435\" \/><\/p>\n<p>\u7528\u4e86\u65ad\u8a00\u540e&#xff0c;\u8fd0\u884c\u662f\u7eff\u8272\u624d\u8bf4\u660e\u662f\u6b63\u786e\u7684\u4ee3\u7801<\/p>\n<p>    \/**<br \/>\n     * \u65ad\u8a00<br \/>\n     *\/<br \/>\n    &#064;Test<br \/>\n    public void testGenderWithAssert(){<br \/>\n        UserService userService &#061; new UserService();<br \/>\n        String gender &#061; userService.getGender(&#034;100000200010011011&#034;);<br \/>\n        \/\/\u65ad\u8a00<br \/>\n        \/\/Assertions.assertEquals(&#034;\u7537&#034;, gender);<br \/>\n        Assertions.assertEquals(&#034;\u7537&#034;, gender, &#034;\u6027\u522b\u83b7\u53d6\u9519\u8bef\u6709\u95ee\u9898&#034;);<br \/>\n    }<\/p>\n<p>\u52a0\u4e0amsg\u63d0\u793a\u4fe1\u606f\u524d\u540e\u533a\u522b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"436\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101304-68304a30a876b.png\" width=\"801\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"460\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101304-68304a30d1e0f.png\" width=\"1083\" \/><\/p>\n<p>        \/\/\u65ad\u8a00<br \/>\n        \/\/Assertions.assertThrows(\u4f60\u671f\u671b\u629b\u51fa\u7684\u5f02\u5e38\u7c7b\u578b.class&#xff0c;() -&gt;{<br \/>\n        \/\/   \u7c7b\u540d.\u65b9\u6cd5\u540d(\u4f60\u629b\u51fa\u7684\u5f02\u5e38\u7ed3\u679c)<br \/>\n        \/\/ }) <\/p>\n<\/p>\n<p>\u5e38\u89c1\u6ce8\u89e3<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"810\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101305-68304a311d92e.png\" width=\"1952\" \/><\/p>\n<p>\u53c2\u6570\u5316\u6ce8\u89e3&#xff1a;\u53ea\u5b9a\u4e49\u4e00\u4e2a\u6d4b\u8bd5\u65b9\u6cd5\u5c31\u53ef\u4ee5\u5b8c\u6210\u4e00\u6279\u6570\u636e\u7684\u6d4b\u8bd5<\/p>\n<p>    \/**<br \/>\n     * \u53c2\u6570\u5316\u6d4b\u8bd5<br \/>\n     *\/<br \/>\n    &#064;DisplayName(&#034;\u6d4b\u8bd5\u7528\u6237\u6027\u522b&#034;)<br \/>\n    &#064;ParameterizedTest<br \/>\n    &#064;ValueSource(strings &#061; {&#034;100000200010011011&#034;,&#034;100000200010011031&#034;,&#034;100000200010011051&#034;})<br \/>\n    public void testGetGender2(String idCard){<br \/>\n        UserService userService &#061; new UserService();<br \/>\n        String gender &#061; userService.getGender(idCard);<br \/>\n        \/\/\u65ad\u8a00<br \/>\n        Assertions.assertEquals(&#034;\u7537&#034;, gender);<br \/>\n    } <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"613\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101305-68304a31b38b9.png\" width=\"1160\" \/><\/p>\n<\/p>\n<p>junit\u4f01\u4e1a\u5f00\u53d1\u89c4\u8303<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"62\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101306-68304a3214670.png\" width=\"1518\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"326\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101306-68304a322b2d7.png\" width=\"692\" \/><\/p>\n<p>\u901a\u8fc7\u8986\u76d6\u7387&#xff0c;\u53ef\u4ee5\u77e5\u9053\u81ea\u5df1\u8003\u8651\u7684\u6d4b\u8bd5\u60c5\u51b5\u5230\u5e95\u5168\u9762\u4e0d\u5168\u9762<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"545\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101306-68304a324229e.png\" width=\"2550\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"504\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101306-68304a32ca22d.png\" width=\"1406\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1528\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101307-68304a33130b5.png\" width=\"2560\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"962\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101308-68304a3461c4b.png\" width=\"754\" \/><\/p>\n<p>\u70b9\u51fb\u5de6\u8fb9\u7684\u7ea2\u7eff\u6761\u53ef\u4ee5\u4ecehits\u77e5\u9053\u5355\u5143\u547d\u4e2d\u7387\u6b21\u6570&#xff08;\u5373\u4f60\u9488\u5bf9\u8fd9\u4e2a\u5355\u5143\u65b9\u6cd5\u6d4b\u8bd5\u7684\u6b21\u6570&#xff09;<\/p>\n<p>\u60f3\u8981\u53ea\u7edf\u8ba1\u67d0\u4e2a\u6d4b\u8bd5\u7c7b\u7684\u8986\u76d6\u7387\u800c\u4e0d\u662f\u67d0\u4e2a\u5305\u7684\u8986\u76d6\u7387<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"599\" src=\"2025-05-23d3jfzrmsfor.png\" width=\"1341\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1137\" src=\"2025-05-23h34brxhkxid.png\" width=\"1690\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"601\" src=\"2025-05-23cwwa5rg2bpe.png\" width=\"982\" \/><\/p>\n<p>\u641c\u7d22\u4f60\u60f3\u7edf\u8ba1\u7684\u6d4b\u8bd5\u7c7b\u540d\u2014\u2014ok\u2014\u2014apply\u2014\u2014ok<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"421\" src=\"2025-05-23cpsm3ueqawd.png\" width=\"896\" \/><\/p>\n<\/p>\n<p>\u501f\u52a9ai\u4f7f\u7528junit<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb450\u6b21\u3002\u70b9\u51fb\u5de6\u8fb9\u7684\u7ea2\u7eff\u6761\u53ef\u4ee5\u4ecehits\u77e5\u9053\u5355\u5143\u547d\u4e2d\u7387\u6b21\u6570\uff08\u5373\u4f60\u9488\u5bf9\u8fd9\u4e2a\u5355\u5143\u65b9\u6cd5\u6d4b\u8bd5\u7684\u6b21\u6570\uff09\u6ce8\u610f\uff1a\u5e76\u4e0d\u662f\u8bf4\u8fd0\u884c\u5230\u662f\u7eff\u8272\u5c31\u8bf4\u660e\u4ee3\u7801\u6ca1\u9519\u3002\u7528main\u65b9\u6cd5\u6d4b\u8bd5\uff0c\u5982\u679c\u4e00\u4e2a\u65b9\u6cd5\u62a5\u9519\uff0c\u5176\u4ed6\u5168\u90e8\u90fd\u4e0d\u80fd\u8fdb\u884c\u6d4b\u8bd5\u4e86\u3002\u53c2\u6570\u5316\u6ce8\u89e3\uff1a\u53ea\u5b9a\u4e49\u4e00\u4e2a\u6d4b\u8bd5\u65b9\u6cd5\u5c31\u53ef\u4ee5\u5b8c\u6210\u4e00\u6279\u6570\u636e\u7684\u6d4b\u8bd5\u3002\u901a\u8fc7\u8986\u76d6\u7387\uff0c\u53ef\u4ee5\u77e5\u9053\u81ea\u5df1\u8003\u8651\u7684\u6d4b\u8bd5\u60c5\u51b5\u5230\u5e95\u5168\u9762\u4e0d\u5168\u9762\u3002\u641c\u7d22\u4f60\u60f3\u7edf\u8ba1\u7684\u6d4b\u8bd5\u7c7b\u540d\u2014\u2014ok\u2014\u2014apply\u2014\u2014ok\u3002\u60f3\u8981\u53ea\u7edf\u8ba1\u67d0\u4e2a\u6d4b\u8bd5\u7c7b\u7684\u8986\u76d6\u7387\u800c\u4e0d\u662f\u67d0\u4e2a\u5305\u7684\u8986\u76d6\u7387\u3002\u7528\u4e86\u65ad\u8a00\u540e\uff0c\u8fd0\u884c\u662f\u7eff\u8272\u624d\u8bf4\u660e\u662f\u6b63\u786e\u7684\u4ee3\u7801\u3002\u52a0\u4e0amsg\u63d0\u793a\u4fe1\u606f\u524d\u540e\u533a\u522b\u3002\u501f\u52a9ai\u4f7f\u7528junit\u3002<\/p>\n","protected":false},"author":2,"featured_media":39402,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2661,1113],"topic":[],"class_list":["post-39422","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-junit","tag-log4j"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>junit\u5355\u5143\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/39422.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"junit\u5355\u5143\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb450\u6b21\u3002\u70b9\u51fb\u5de6\u8fb9\u7684\u7ea2\u7eff\u6761\u53ef\u4ee5\u4ecehits\u77e5\u9053\u5355\u5143\u547d\u4e2d\u7387\u6b21\u6570\uff08\u5373\u4f60\u9488\u5bf9\u8fd9\u4e2a\u5355\u5143\u65b9\u6cd5\u6d4b\u8bd5\u7684\u6b21\u6570\uff09\u6ce8\u610f\uff1a\u5e76\u4e0d\u662f\u8bf4\u8fd0\u884c\u5230\u662f\u7eff\u8272\u5c31\u8bf4\u660e\u4ee3\u7801\u6ca1\u9519\u3002\u7528main\u65b9\u6cd5\u6d4b\u8bd5\uff0c\u5982\u679c\u4e00\u4e2a\u65b9\u6cd5\u62a5\u9519\uff0c\u5176\u4ed6\u5168\u90e8\u90fd\u4e0d\u80fd\u8fdb\u884c\u6d4b\u8bd5\u4e86\u3002\u53c2\u6570\u5316\u6ce8\u89e3\uff1a\u53ea\u5b9a\u4e49\u4e00\u4e2a\u6d4b\u8bd5\u65b9\u6cd5\u5c31\u53ef\u4ee5\u5b8c\u6210\u4e00\u6279\u6570\u636e\u7684\u6d4b\u8bd5\u3002\u901a\u8fc7\u8986\u76d6\u7387\uff0c\u53ef\u4ee5\u77e5\u9053\u81ea\u5df1\u8003\u8651\u7684\u6d4b\u8bd5\u60c5\u51b5\u5230\u5e95\u5168\u9762\u4e0d\u5168\u9762\u3002\u641c\u7d22\u4f60\u60f3\u7edf\u8ba1\u7684\u6d4b\u8bd5\u7c7b\u540d\u2014\u2014ok\u2014\u2014apply\u2014\u2014ok\u3002\u60f3\u8981\u53ea\u7edf\u8ba1\u67d0\u4e2a\u6d4b\u8bd5\u7c7b\u7684\u8986\u76d6\u7387\u800c\u4e0d\u662f\u67d0\u4e2a\u5305\u7684\u8986\u76d6\u7387\u3002\u7528\u4e86\u65ad\u8a00\u540e\uff0c\u8fd0\u884c\u662f\u7eff\u8272\u624d\u8bf4\u660e\u662f\u6b63\u786e\u7684\u4ee3\u7801\u3002\u52a0\u4e0amsg\u63d0\u793a\u4fe1\u606f\u524d\u540e\u533a\u522b\u3002\u501f\u52a9ai\u4f7f\u7528junit\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/39422.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-23T10:13:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101300-68304a2c11173.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39422.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/39422.html\",\"name\":\"junit\u5355\u5143\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-23T10:13:09+00:00\",\"dateModified\":\"2025-05-23T10:13:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/39422.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/39422.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39422.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"junit\u5355\u5143\u6d4b\u8bd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"junit\u5355\u5143\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/39422.html","og_locale":"zh_CN","og_type":"article","og_title":"junit\u5355\u5143\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb450\u6b21\u3002\u70b9\u51fb\u5de6\u8fb9\u7684\u7ea2\u7eff\u6761\u53ef\u4ee5\u4ecehits\u77e5\u9053\u5355\u5143\u547d\u4e2d\u7387\u6b21\u6570\uff08\u5373\u4f60\u9488\u5bf9\u8fd9\u4e2a\u5355\u5143\u65b9\u6cd5\u6d4b\u8bd5\u7684\u6b21\u6570\uff09\u6ce8\u610f\uff1a\u5e76\u4e0d\u662f\u8bf4\u8fd0\u884c\u5230\u662f\u7eff\u8272\u5c31\u8bf4\u660e\u4ee3\u7801\u6ca1\u9519\u3002\u7528main\u65b9\u6cd5\u6d4b\u8bd5\uff0c\u5982\u679c\u4e00\u4e2a\u65b9\u6cd5\u62a5\u9519\uff0c\u5176\u4ed6\u5168\u90e8\u90fd\u4e0d\u80fd\u8fdb\u884c\u6d4b\u8bd5\u4e86\u3002\u53c2\u6570\u5316\u6ce8\u89e3\uff1a\u53ea\u5b9a\u4e49\u4e00\u4e2a\u6d4b\u8bd5\u65b9\u6cd5\u5c31\u53ef\u4ee5\u5b8c\u6210\u4e00\u6279\u6570\u636e\u7684\u6d4b\u8bd5\u3002\u901a\u8fc7\u8986\u76d6\u7387\uff0c\u53ef\u4ee5\u77e5\u9053\u81ea\u5df1\u8003\u8651\u7684\u6d4b\u8bd5\u60c5\u51b5\u5230\u5e95\u5168\u9762\u4e0d\u5168\u9762\u3002\u641c\u7d22\u4f60\u60f3\u7edf\u8ba1\u7684\u6d4b\u8bd5\u7c7b\u540d\u2014\u2014ok\u2014\u2014apply\u2014\u2014ok\u3002\u60f3\u8981\u53ea\u7edf\u8ba1\u67d0\u4e2a\u6d4b\u8bd5\u7c7b\u7684\u8986\u76d6\u7387\u800c\u4e0d\u662f\u67d0\u4e2a\u5305\u7684\u8986\u76d6\u7387\u3002\u7528\u4e86\u65ad\u8a00\u540e\uff0c\u8fd0\u884c\u662f\u7eff\u8272\u624d\u8bf4\u660e\u662f\u6b63\u786e\u7684\u4ee3\u7801\u3002\u52a0\u4e0amsg\u63d0\u793a\u4fe1\u606f\u524d\u540e\u533a\u522b\u3002\u501f\u52a9ai\u4f7f\u7528junit\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/39422.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-23T10:13:09+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250523101300-68304a2c11173.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/39422.html","url":"https:\/\/www.wsisp.com\/helps\/39422.html","name":"junit\u5355\u5143\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-23T10:13:09+00:00","dateModified":"2025-05-23T10:13:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/39422.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/39422.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/39422.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"junit\u5355\u5143\u6d4b\u8bd5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/39422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=39422"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/39422\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/39402"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=39422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=39422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=39422"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=39422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}