本文介绍了如何在没有XML文件的TestNG中创建TestSuite类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I Want to run Sanity.java and regression.java together so I've created TestSuite.java in junit and it is working. Now I want create the same using TestNG, plz help me..

下面是我的junit框架代码:

Below is my junit framework code:

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测试类.参见下面的示例

You can run testNG test classes from your program. See example below

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

您可以使用上述代码在套件类中设置要运行的测试类.另外,有关以编程方式运行testNG的更多详细信息,请参阅此链接

You can set the test classes you want to run in your suite class by using above code. Also for more details on running testNG programatically please refer this link

这篇关于如何在没有XML文件的TestNG中创建TestSuite类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 18:11