Selenium webdriver 如何在没有xml文件的TestNG中创建TestSuite类

Selenium webdriver 如何在没有xml文件的TestNG中创建TestSuite类,selenium-webdriver,testng,Selenium Webdriver,Testng,我想同时运行Sanity.java和regression.java,所以我已经在junit中创建了TestSuite.java,它正在工作。现在我想使用TestNG创建相同的,请帮助我 下面是我的junit框架代码: package com.abc.def; import org.junit.runner.RunWith; import org.junit.runners.Suite; import com.auto.tests.abc1; import com.auto.tests.abc

我想同时运行Sanity.java和regression.java,所以我已经在junit中创建了TestSuite.java,它正在工作。现在我想使用TestNG创建相同的,请帮助我

下面是我的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 {

}

您可以从程序中运行testNG测试类。见下面的例子

TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { Run2.class });
testng.addListener(tla);
testng.run();
您可以使用上述代码设置要在套件类中运行的测试类。有关以编程方式运行testNG的更多详细信息,请参阅