0

I have this testng suite segregated under test tag.

This is different interms of other issues (TestNG surefire, run suite with maven command line). Here I need to execute set of classes under test tag not specific class nor specific package.

<suite name="Suite1" verbose="1" >
      <test name="set-1" >
        <classes>
           <class name="com.test.ejb.AdminServiceTest" />
           ....
        </classes>
      </test>
      <test name="set-2">
        <classes>
            <class name="com.test.ejb.ServiceTestBase" />
            ...
        </classes>
      </test>
        <test name="set-3">
        <classes>
            <class name="com.test.ejb.RazakIeraTest" />
            ...
        </classes>
      </test>
        <test name="set-4">
        <classes>
            <class name="com.test.ejb.PayCheckTest" />
            ...
        </classes>
      </test>
    </suite>

I have a suite with a grouping of classes under test tag. I would like to execute only one test tag.

We have a way to select single class using this cmd mvn test -Dtest="className".

I have tried -Dtestnames=set-5 (http://testng.org/doc/documentation-main.html). but it did not work.

Do we have any way to execute test tag using maven command ?.

Abdul Razak AK
  • 405
  • 1
  • 7
  • 17
  • Possible duplicate of [TestNG surefire, run suite with maven command line](https://stackoverflow.com/questions/10391312/testng-surefire-run-suite-with-maven-command-line) – Nick DeFazio Nov 22 '17 at 15:02
  • @NickDeFazio I got a way to select single class,specific package and specific method in a particular class. Is there a way to execute set of class under tag ? – Abdul Razak AK Nov 22 '17 at 15:08
  • Do you want to run just one test by name ? can you use command line instead of maven? – user1207289 Nov 22 '17 at 15:19
  • Yes @user1207289. I would like to run just set-1 (classes under test tag). Yes Please provide a way to run single test by command line – Abdul Razak AK Nov 22 '17 at 15:21

2 Answers2

0

You can use the below command

java -cp ".\bin;.\lib\*;" org.testng.TestNG testng.xml -testnames Test1

you can also provide a list of test names in -testnames parameter

Have a look here

user1207289
  • 3,060
  • 6
  • 30
  • 66
0

I assume you use maven with maven-surefire-plugin to run your tests, right?

Then in the properties section of the plugin add 'testname' with some variable as a value

<properties>
    <property>
        <name>testnames</name>
        <value>${testng.testnames}</value>
    </property>
</properties>

You can filter your tests by specifying value of the variable

mvn test -Dtestng.testnames=set-1,set-2
Mihail
  • 241
  • 1
  • 6