TestNG is a java framework useful to execute the Unit Tests in a java project. We can even TestNG to automate the Selenium Tests in the Project.In TestNG xml file, the execution of Tests is managed by setting the “parallel” attribute and “thread-count” attribute in the suite xml as follows:
|
|
|
|
Now the question arises that how can we execute multiple Testng xml files in the project. The solution is as follows:
<suite name=”Running Suite Files” verbose=”1″ preserve-order=”true”> <listeners> <listener class-name=”org.testng.reporters.VerboseReporter”/> </listeners> <suite-files> <suite-file path=”testng1.xml”/> <suite-file path=”testng2.xml”/> </suite-files> </suite> |
How do we execute these suite-of-suite files parallely?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package org.totalqa.tests; import java.util.ArrayList; import java.util.List; import org.testng.TestListenerAdapter; import org.testng.TestNG; public class ParallelSuites { public static void main(String[] args) { TestNG testng = new TestNG(); TestListenerAdapter adapter = new TestListenerAdapter(); List<String> suites = new ArrayList<String>(); testng.addListener(adapter); suites.add("Suite.xml"); testng.setTestSuites(suites); testng.setParallel("parallel"); testng.setSuiteThreadPoolSize(5); testng.setOutputDirectory(System.getProperty("user.dir")+"//target"); testng.run(); } } |
Conclusion::
Execution of the ParallelSuites.java program, stores the Results in the output folder.Make sure the Project is refreshed to view the results as mentioned below:
its not working, did you add anything to pom.xml