开发者

invoking only the required test in testng file while using ant

开发者 https://www.devze.com 2023-04-10 12:33 出处:网络
I am trying to invoke tests of a testng.xml file from ant. My testng.xml looks like the following: <suite name=\"testsuite\">

I am trying to invoke tests of a testng.xml file from ant.

My testng.xml looks like the following:

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

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

Now, I want to run only the "test1" tests and not those of "test2开发者_运维问答". Is there a way (parameter?) to tell the ant build.xml file to do this?

<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>


Look up -testnames in the documentation (note: plural).


The xml files are there for exacly that: not running all tests from a class file containing tests. As I see it, the intended way to go would be to change the existing xml file, or create a new one.

Still, if your tests are included in different class files (I cannot see this from your example code), you could specify a classfileset instead of an xmlfileset, e.g.:

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号