{"id":810,"date":"2023-03-01T06:47:09","date_gmt":"2023-02-28T22:47:09","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=810"},"modified":"2023-04-05T17:32:09","modified_gmt":"2023-04-05T09:32:09","slug":"testng-run-junit-tests","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/01\/testng-run-junit-tests\/","title":{"rendered":"TestNG\u8fd0\u884cJUnit\u6d4b\u8bd5"},"content":{"rendered":"<p>TestNG\u53ef\u4ee5\u81ea\u52a8\u8bc6\u522b\u548c\u8fd0\u884cJUnit\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u4f7f\u7528TestNG\u6267\u884c\u73b0\u6709JUnit\u6d4b\u8bd5\u7528\u4f8b\u3002\u5728JUnit 4\u4e2d\uff0cTestNG \u4f1a\u81ea\u52a8\u8c03\u7528 org.junit.runner.JUnitCore \u8fd0\u884c\u6d4b\u8bd5\u3002<\/p>\n<p>\u6267\u884cJUnit\u6d4b\u8bd5\u7528\u4f8b\uff0c\u9700\u8981\u5728testng.xml\u4e2d\u5b9a\u4e49\u5c5e\u6027<code>junit=&quot;true&quot;<\/code><\/p>\n<p><!-- more --><\/p>\n<p>JunitTest.java<\/p>\n<pre><code class=\"language-java\">package me.yezhou;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class JunitTest {\n    @Test\n    public void testEquals() {\n        String str = &quot;Junit testing using TestNG&quot;;\n        Assert.assertEquals(&quot;Junit testing using TestNG&quot;, str);\n    }\n}<\/code><\/pre>\n<p>junit.xml<\/p>\n<pre><code class=\"language-xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;!DOCTYPE suite SYSTEM &quot;http:\/\/testng.org\/testng-1.0.dtd&quot; &gt;\n&lt;suite name=&quot;Converted JUnit Suite&quot;&gt;\n    &lt;test name=&quot;JUnitTests&quot; junit=&quot;true&quot;&gt;\n        &lt;classes&gt;\n            &lt;class name=&quot;me.yezhou.JunitTest&quot;\/&gt;\n        &lt;\/classes&gt;\n    &lt;\/test&gt;\n&lt;\/suite&gt;<\/code><\/pre>\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/p>\n<pre><code>===============================================\nConverted JUnit Suite\nTotal tests run: 1, Failures: 0, Skips: 0\n===============================================<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>TestNG\u53ef\u4ee5\u81ea\u52a8\u8bc6\u522b\u548c\u8fd0\u884cJUnit\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u4f7f\u7528TestNG\u6267\u884c\u73b0\u6709JUnit\u6d4b\u8bd5\u7528\u4f8b\u3002\u5728JUnit 4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[224],"tags":[],"class_list":["post-810","post","type-post","status-publish","format-standard","hentry","category-testng"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=810"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/810\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}