I'm invoking TestNG from the command-line like this:
java org.testng.TestNG -groups "foo" testng.xml
...with the intention of only running tests annotated with:
@Test(groups = { "foo" })
...but it's running all my tests. Do I need to change my testng.xml file?
<suite name="BarSuite" verbose="1">
<test name="AllInPackage">
<packages>
<package name="com.example.bar"/>
</packages>
</test>
</suite>
Is TestNG ignoring the -groups command-line argument because testng.xml says to run all the tests in the package? If so, how should I change my testng.xml file?
You got it exactly right: if you specify a testng.xml, it takes precedence over the command line switches.
Just add the following to your XML file:
<groups>
<run>
<include name="foo" />
</run>
</groups>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With