How do I get TestNG to run tests in a specific group (from the command line)?


Daryl Spitzer:

I call TestNG from the command line like this:

java org.testng.TestNG -groups "foo" testng.xml

...only for running tests annotated with:

@Test(groups = { "foo" })

...but it is 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>

Does TestNG ignore the -groups command line argument because testng.xml says to run all tests in the package? If so, how should I change the testng.xml file?

Cedric Beust:

You are absolutely right: if testng.xml is specified, it will take precedence over command line switches.

Just add the following to your XML file:

  <groups>
    <run>
      <include name="foo"  />
    </run>
  </groups>

Related


How to run TestNG from the command line

Fuzzy Analysis: How to run .java TestNG project from command line? I've read the TestNG documentation and tried the following to no avail: C:\projectfred> java org.testng.TestNG testng.xml ...with the following testng.xml file in my project: <!DOCTYPE suite

How to run TestNG from the command line

Fuzzy Analysis: How to run .java TestNG project from command line? I've read the TestNG documentation and tried the following to no avail: C:\projectfred> java org.testng.TestNG testng.xml ...with the following testng.xml file in my project: <!DOCTYPE suite

How do you run tests from the command line?

Doug To make this internal edit, open the Automation tab, connect to a session and select the test to run. How do you do this from the command line? (Note: Not Compiling UnrealEngine/Engine/Build/BatchFiles/* comprehensively covers building an application and

How do you run tests from the command line?

Doug To make this internal edit, open the Automation tab, connect to a session and select the test to run. How do you do this from the command line? (Note: Not Compiling UnrealEngine/Engine/Build/BatchFiles/* comprehensively covers building an application and

How do you run tests from the command line?

Doug To make this internal edit, open the Automation tab, connect to a session and select the test to run. How do you do this from the command line? (Note: Not Compiling UnrealEngine/Engine/Build/BatchFiles/* comprehensively covers building an application and

How do you run tests from the command line?

Doug To make this internal edit, open the Automation tab, connect to a session and select the test to run. How do you do this from the command line? (Note: Not Compiling UnrealEngine/Engine/Build/BatchFiles/* comprehensively covers building an application and

How do I install a script to run anywhere from the command line?

jeffbr13: If I have a basic Python script with a hashbang and something that doesn't exist, I can run it from a terminal on Linux /path/to/file/MyScript [args] It will execute the program without going through the interpreter or any file extension. So I will

How do I install a script to run anywhere from the command line?

jeffbr13: If I have a basic Python script with a hashbang and something that doesn't exist, I can run it from a terminal on Linux /path/to/file/MyScript [args] It will execute the program without going through the interpreter or any file extension. So I will

How do I run a Groovy script for Java from the command line?

Ripper 234: I'm trying to use groovyc, but something is not right: >echo println("Hello world") > test.groovy >groovy test.groovy Hello world >groovyc test.groovy >java -cp C:\utils\groovy-1.8.1\embeddable\groovy-all-1.8.1.jar test Error: Could not find or loa

How do I run Clozure CL from the Windows command line?

Jesse Rooney I'm trying to install Clozure CL with my own instructions and want me to add the files ccland ccl64my way, but they have no file extensions and Windows doesn't know how to run them. I ended up looking at the files and it starts with #!/bin/sh. As

How do I run Clozure CL from the Windows command line?

Jesse Rooney I'm trying to install Clozure CL with my own instructions and want me to add the files ccland ccl64my way, but they have no file extensions and Windows doesn't know how to run them. I ended up looking at the files and it starts with #!/bin/sh. As

How do I run a karate test from the command line?

Memo I created my project using the archetype found in the documentation. However, the tests cannot be run from the command line. All tests are ignored. I'm running it and even mvn testif I specify mvn test -Dtest=SystemTestsRunnerit it gives me an exception t

How do I run a Chrome app from the command line?

octave reference I am new to linux and just installed Elementary OS. I installed Chrome and noticed that Workflowy and many other Chrome apps were also installed as shown in the screenshot. But how do I find the command to run a Chrome app (e.g. workflow)? (so

How do I install a script to run anywhere from the command line?

jeffbr13: If I have a basic Python script with a hashbang and something that doesn't exist, I can run it from a terminal on Linux /path/to/file/MyScript [args] It will execute the program without going through the interpreter or any file extension. So I will

How do I run a Groovy script for Java from the command line?

Ripper 234: I'm trying to use groovyc, but something is not right: >echo println("Hello world") > test.groovy >groovy test.groovy Hello world >groovyc test.groovy >java -cp C:\utils\groovy-1.8.1\embeddable\groovy-all-1.8.1.jar test Error: Could not find or loa

How do I run a karate test from the command line?

Memo I created my project using the archetype found in the documentation. However, the tests cannot be run from the command line. All tests are ignored. I'm running it and even mvn testif I specify mvn test -Dtest=SystemTestsRunnerit it gives me an exception t

How do I run a karate test from the command line?

Memo I created my project using the archetype found in the documentation. However, the tests cannot be run from the command line. All tests are ignored. I'm running it and even mvn testif I specify mvn test -Dtest=SystemTestsRunnerit it gives me an exception t

How do I run a Chrome app from the command line?

octave reference I am new to linux and just installed Elementary OS. I installed Chrome and noticed that Workflowy and many other Chrome apps were also installed as shown in the screenshot. But how do I find the command to run a Chrome app (e.g. workflow)? (so