2014-02-05 64 views
1

我想一起運行Sanity.java和regression.java,因此我在junit中創建了TestSuite.java並且它正在工作。現在我想創建用TestNG一樣,plz幫助我..如何在不帶xml文件的TestNG中創建TestSuite類

下面是我的JUnit框架代碼:

package com.abc.def; 

import org.junit.runner.RunWith; 
import org.junit.runners.Suite; 

import com.auto.tests.abc1; 
import com.auto.tests.abc2; 
import com.auto.tests.abc3; 
import com.auto.tests.abc4; 


@RunWith(Suite.class) 
@Suite.SuiteClasses({abc1.class, abc2.class,abc3.class,abc4.class}) 
public class abcTestSuite { 

} 

回答

0

你可以從你的程序運行TestNG的測試類。看下面的例子

TestListenerAdapter tla = new TestListenerAdapter(); 
TestNG testng = new TestNG(); 
testng.setTestClasses(new Class[] { Run2.class }); 
testng.addListener(tla); 
testng.run(); 

你可以通過使用上面的代碼來設置你想要在套件類中運行的測試類。關於以編程方式運行testNG的更多細節,請參考此link