0

我正在尝试从 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>
4

2 回答 2

1

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

于 2011-10-05T04:40:17.957 回答
0

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>
于 2012-11-28T13:54:41.227 回答