Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/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
在使用ant时仅调用testng文件中所需的测试_Ant_Testng_Build.xml - Fatal编程技术网

在使用ant时仅调用testng文件中所需的测试

在使用ant时仅调用testng文件中所需的测试,ant,testng,build.xml,Ant,Testng,Build.xml,我试图从ant调用testng.xml文件的测试 我的testng.xml如下所示: <suite name="testsuite"> bunch of parameters here <test name="test1"> </test> <test name="test2"> </test> </suite> 这里有一堆参数 现在,我只想运行“test1”测试,而不是“test2”测

我试图从ant调用testng.xml文件的测试

我的testng.xml如下所示:

<suite name="testsuite">
   bunch of parameters here
   <test name="test1">
   </test>

   <test name="test2">
   </test>
</suite>

这里有一堆参数
现在,我只想运行“test1”测试,而不是“test2”测试。是否有方法(参数?)告诉ant build.xml文件执行此操作

<testng classpathref="testng.class.path" delegateCommandSystemProperties="true" 
            outputDir="${test-output}" haltOnfailure="false" useDefaultListeners="true" 
            parallel="methods"
            failureproperty="test.failure">
            <xmlfileset file="testng.xml"/>
            <!--forked JVM OOM issue-->
            <jvmarg value="-Xmx512M"/>
            <jvmarg value="-Xms512M"/>
            <jvmarg value="-Xmn192M"/>
            <jvmarg value="-XX:PermSize=128M"/>
            <jvmarg value="-XX:MaxPermSize=128M"/>

        </testng>


在中查找
-testnames
(注意:复数)。

xml文件存在,例如:不从包含测试的类文件运行所有测试。在我看来,预期的方法是更改现有的xml文件,或者创建一个新的xml文件

但是,如果您的测试包含在不同的类文件中(我从示例代码中看不到这一点),您可以指定一个类文件集而不是xmlfileset,例如:

<testng  workingDir="../../" outputdir="${output_dir}" 
                verbose="2" listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter"
                classpathref="testsClasspath">
                <classfileset dir="./${test_classes}/com/my/organization" includes="MyTest.class" />
            </testng>


Hi Cedric,感谢您的回复。我在文档中找不到-testnames。您能否提供一个示例,说明如何使用它或通过此参数实际传递值?它就在“Running TestNG”部分:-testnames一个以逗号分隔的测试名称列表。只有在与这些名称之一匹配的标记中定义的测试才会运行。嗨,我昨天找到并使用了它。但它不起作用。它基本上运行testng文件中的所有块。不确定我是否正确使用了它。你能帮我举个例子吗。。