Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从JUnit到TestNG:如何转换@SuiteClasses?_Junit_Porting_Testng - Fatal编程技术网

从JUnit到TestNG:如何转换@SuiteClasses?

从JUnit到TestNG:如何转换@SuiteClasses?,junit,porting,testng,Junit,Porting,Testng,我正在将为JUnit4+编写的大量测试用例转换为使用TestNG。我发现测试类级别的注释大部分是相似的,并且可以很容易地替换(例如,@Before=>@beforethod)。然而,转换测试套件更为棘手。例如,我设计了一系列测试套件,使用JUnit的@SuiteClasses注释运行: import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClass

我正在将为JUnit4+编写的大量测试用例转换为使用TestNG。我发现测试类级别的注释大部分是相似的,并且可以很容易地替换(例如,
@Before
=>
@beforethod
)。然而,转换测试套件更为棘手。例如,我设计了一系列测试套件,使用JUnit的
@SuiteClasses
注释运行:

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

@RunWith(Suite.class)
@SuiteClasses({ Foo.class, Bar.class, Baz.class, subpackage.AllTests.class })
public class AllTests {}

将此类类转换为TestNG认可的套件的最佳方式是什么?我是否应该编写一个脚本来为每个类生成相应的
some_suite.xml
?有更好的方法吗?

您可以创建一个.xml文件(我建议您这样做,因为它将使您的生活更轻松,最终,.xml将包含您的整个测试套件),或者您可以使用TestNG API,这非常简单。这是你的电话号码