testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.98k stars 1.02k forks source link

Run all TestNG tests in a package specified on the command line #1226

Open numeralnathan opened 7 years ago

numeralnathan commented 7 years ago

Using the following XML file, I can run all of the tests in the some.package.login Java package.

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

 <suite name="Login">
   <test name="Login">
     <packages>
       <package name="some.package.login"/>
     </packages>
   </test>
 </suite>

I would like to run TestNG from the command line which does the same as the above XML file but without the XML file. I know about the -suitename parameter. I just don't know how to limit the execution to a specific package.

I tried -testclass some.package.login.* but TestNG treats this as a name of a class and doesn't handle wild cards.

I could use -groups and then use @Test(groups = "Login") on all of the tests but I would rather not have to do that.

I am looking for a solution which is easier than creating an XML file for each subset of tests I want to run. Writing a class for each subset isn't any easier than writing an XML file.

Here's my StackOverflow question looking for a solution. http://stackoverflow.com/questions/40346375/run-all-testng-tests-in-a-package-specified-on-the-command-line

juherr commented 7 years ago

Thanks for the idea. I've just proposed you a workaround on stackoverflow.