Search code examples
intellij-ideatestngtest-suite

Is it possible to run several TestNG suite files in one configuration in IntelliJ IDEA?


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.


Solution

  • 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.