5

I have several TestNG suite files across my multi-module java project, it's structure looks like this:

project\
  module1\src\test\resources\
    suite1.xml
    suite2.xml
  module2\src\test\resources\
    suite3.xml

Is it possible to create run configuration including all these suites in IntelliJ IDEA?

I am able to create separate configuration for each of them via Run/Debug Configurations - TestNG - Configuration - Suite, but I don't see a way to select multiple files there.

I cannot merge all test suites into single suite because some tests use Before/After Suite methods.

I am using IntelliJ IDEA 14.1.2 Community edition, TestNG 6.1.1.

arghtype
  • 4,376
  • 11
  • 45
  • 60
  • 1
    Is creating a master suite an option for you? Then you could reference the other files with `suite-files` (I think it was), and running this master suite. – stuXnet Aug 06 '15 at 09:00
  • @stuXnet thanks, I missed this feature somehow, I'll give it a try! – arghtype Aug 06 '15 at 09:06
  • I accidentally stumbled over it when editing a suite file in IntelliJ, that's when I saw this tag. Sadly, it's not documented in the otherwise awesome documentation - http://testng.org/doc/documentation-main.html – stuXnet Aug 06 '15 at 09:10

1 Answers1

12

TestNG per se supports the execution of multiple suite files - you can run java org.testng.TestNG suite1.xml suite2.xml suite3.xml

I haven't found a way to specify multiple suite.xmls in IntelliJ, so I created a master suite using the undocumented suite-files tag. It looks like this:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Suite1" verbose="1" >
    <suite-files>
        <suite-file path="suite1.xml"/>
        <suite-file path="suite2.xml"/>
    </suite-files>
</suite>

This suite file is runnable by IntelliJ and should include all tests, with their correct before/after methods.

stuXnet
  • 4,309
  • 3
  • 22
  • 31
  • 1
    it worked, thank you. But it seems like I have to update my test suites carefully: I have very greedy patterns, like 'include package "com.a.b.*" ' in test-suites of module1, but I also have such packages in module2. And (no surprise) suite from module1 makes attempts to run tests from module2, and obviously fails :) – arghtype Aug 06 '15 at 09:44
  • http://testng.org/testng-1.0.dtd.php <!ELEMENT suite (groups?,(listeners|packages|test|parameter|method-selectors|suite-files)*) > – user77115 Aug 23 '17 at 11:26
  • Is there a way to use enable/disable flag for additional control in .? Objective is to enable/disable suite-files from a single location of root/master suite testng.xml file – vinsinraw May 07 '21 at 12:26