gpt4 book ai didi

java - 将 JUnitCore ( JUnit ) 更改为 TestNG

转载 作者:行者123 更新时间:2023-12-04 05:12:51 25 4
gpt4 key购买 nike

我正在尝试修改以下使用 JUnit 的代码以使用 TestNG。

公共(public)类 AutotestShellRunner {

static Class<?> autotestClass;
static org.junit.runner.Result junitResult; ( I replaced that with org.testng.ITestResult )

public static void main(final String[] args) {
int rc;
if (args.length != 2) {
System.err.println("Usage: AutotestShellRunnerDrive <TEST_SCENARIO_CLASS_NAME> <TEST_CASE>");
System.exit(-1);
}

final String testsuite = args[0];
final String testcase = args[1];

try {
autotestClass = Class.forName(testsuite);
} catch (final ClassNotFoundException e) {t
e.printStackTrace();
throw new RuntimeException("class" + testsuite + " is not found ", e);
}
junitResult = (new JUnitCore()).run(Request.method(autotestClass, testcase)); //Now from what i saw i can use instead of JUnitCore I use TestNG

The problem is that TestNG.run() is not recieving any arguments that I need to pass such as auttestClass and testcase
Does anyone have any idea?

Thanks,
Nir

最佳答案

使用 TestNG 的编程 API,here is the documentation .

关于java - 将 JUnitCore ( JUnit ) 更改为 TestNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14671122/

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