Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/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
使eclipse在构建时自动运行testNG测试_Eclipse_Eclipse Plugin_Testng - Fatal编程技术网

使eclipse在构建时自动运行testNG测试

使eclipse在构建时自动运行testNG测试,eclipse,eclipse-plugin,testng,Eclipse,Eclipse Plugin,Testng,怎么做 我可以制作一个ant脚本,但据我所知,它不会在eclipse窗口中显示结果。的TestNG站点上有说明。当然,您需要将测试代码放在诸如src/tests/com/test/mytests之类的目录中,或者类似的目录中,作为项目中的独立源代码树。然后,您的Ant脚本应该能够调用它 TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClass

怎么做


我可以制作一个ant脚本,但据我所知,它不会在eclipse窗口中显示结果。

的TestNG站点上有说明。当然,您需要将测试代码放在诸如src/tests/com/test/mytests之类的目录中,或者类似的目录中,作为项目中的独立源代码树。然后,您的Ant脚本应该能够调用它

TestListenerAdapter tla = new TestListenerAdapter();  
TestNG testng = new TestNG();  
testng.setTestClasses(new Class[] { 'tests/com/test/mytests/Run2.class' });  
testng.addListener(tla);  
testng.run(); 

我自己也没有尝试过,所以我的建议可能会引起您的不同。

不确定,但我会先看看项目建设者。在eclipse项目的属性中,可以定义构建器。这些可以定义为在某些事件(如生成)上触发。您确定这是您想要的吗?每次源文件更改时,Eclipse都会进行增量构建。是否确实要在每次保存时运行所有测试?另一种可能是在每次保存时运行测试子集。但是,如何选择要运行的子集?在这种情况下,Infinitest可能会有所帮助,但我认为它不适用于TestNG。如果我通过EclipseBuilder机制来实现,那么我认为我将无法在eclipse窗口中看到结果。由于我将要使用它的项目很小,所以在每个构建上运行测试不会占用太多资源。