Hi Zaid, Suites are used to execute multiple tests together. Suites can be created using both TestNG and JUnit4. But, suites are more powerful in TestNG as it uses very different method for execution of tests. So, it is better to use TestNG Suite rather than using Junit Suite. TestNG can do more than bundle class testing, it can do bundle method testing as well. With TestNG unique “Grouping” concept, every method is tie to a group, it can categorize tests according to features. For eg.
In JUnit, the “@RunWith” and “@Suite” are use to run the suite test. The below class means both unit test “JunitTest1” and “JunitTest2” run together after JunitTest5 executed:
@RunWith(Suite.class)
@Suite.SuiteClasses({
JunitTest1.class,
JunitTest2.class
})
public class JunitTest5 {
}
While in TestNG, XML file is use to run the suite test. The below XML file means both unit test “TestNGTest1” and “TestNGTest2” will run it together:
<suite name="My test suite">
<test name="testing">
<classes>
<class name="com.fsecure.demo.testng.TestNGTest1" />
<class name="com.fsecure.demo.testng.TestNGTest2" />
</classes>
</test>
</suite>