Suppose we have application with multiple modules(say 20 modules).
If you want to create suite file for each module then we will have 20 suite file(i.e. one suite file for each module, since easy to maintain), if you want execute the test scripts for all the modules then you need to execute all the suite files one after the other.
Is there any way to integrate all the suite files in single suite file(i.e. Main Suite file / Final Suite file).
Yes, there is a solution to integrate all the suite files in Final Suite file / Main Suite file.
Below steps/procedure show's to integrate multiple suite files in single suite file.
TestNG Sample Program's
Module 1:
package module1;
import org.testng.annotations.Test;
public class Test1 {
@Test
public void test1() {
System.out.println("test1 of module1...");
}
}
Module 2:
package module2;
import org.testng.annotations.Test;
public class Test2 {
@Test
public void test2() {
System.out.println("test2 of module2...");
}
}
Sample Suite Files for each module:
Suite_Module1.xml :
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite_module1" parallel="false">
<test name="Test">
<classes>
<class name="module1.Test1"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Suite_Module2.xml :
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite_module2" parallel="false">
<test name="Test">
<classes>
<class name="module2.Test2"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Final (or) Main Suite File:
Final_Suite.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite name="All Suite Files">
<suite-files>
<suite-file path="Suite_Module1.xml" />
<suite-file path="Suite_Module2.xml" />
</suite-files> <!-- Suite files-->
</suite> <!-- Suite -->
Now execute the Final Suite file(i.e Final_Suite.xml):\
Output:
------------------------------------------------------------------------------------
[TestNG] Running:
D:\V_Drive\SW Testing\WDriver\TestNG Proj\src\Suite_Module1.xml
test1 of module1...
===============================================
Suite_module1
Total tests run: 1, Failures: 0, Skips: 0
===============================================
[TestNG] Running:
D:\V_Drive\SW Testing\WDriver\TestNG Proj\src\Suite_Module2.xml
test2 of module2...
===============================================
Suite_module2
Total tests run: 1, Failures: 0, Skips: 0
===============================================
[TestNG] Running:
D:\V_Drive\SW Testing\WDriver\TestNG Proj\src\Final_Suite.xml
===============================================
All Suite Files
Total tests run: 2, Failures: 0, Skips: 0
===============================================
------------------------------------------------------------------------------------