1. 程式人生 > >TestNG在java中執行命令列

TestNG在java中執行命令列

1、配置好java環境(在環境變數中,具體內容參見網上) 2、安裝好eclipse,並能夠正常使用,並配置testng環境(不詳細舉例,可以從網上其他地方參考) 3、新建一個專案:test,建立一個包:test;並在包下建立類:TestngAnnotation; TestngAnnotation內容如下: package test; import org.testng.annotations.Test; public class TestngAnnotation{     // test case 1     @Test     public void testCase1() {         System.out.println("in test case 1");     } } 4、在src下建立testng.xml檔案:內容如下: <?xml version="1.0" encoding="UTF-8"?> <suite name="Suite1">   <test name="test1">     <classes>        <class name="test.TestngAnnotation"/>     </classes>   </test> </suite>    5、完成以上後儲存,開啟dos視窗(cmd): 指定到上面生成檔案的路徑(..\..\src下):輸入命令:javac test/TestngAnnotation.java,執行後會生成一個class檔案(如下圖)
6、上一步驟完成後,繼續輸入命令:java org.testng.TestNG testng.xml,執行後,會生成如下內容: