gpt4 book ai didi

selenium-webdriver - 如何在没有xml文件的情况下在TestNG中创建TestSuite类

转载 作者:行者123 更新时间:2023-12-03 10:02:45 25 4
gpt4 key购买 nike

我想同时运行 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 的更多详细信息,请参阅此 link

关于selenium-webdriver - 如何在没有xml文件的情况下在TestNG中创建TestSuite类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21577547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com