Since Selenium does not support report generation and test case management, we use TestNG framework with Selenium. TestNG is much more advanced than JUnit, and it makes implementing annotations easy. That is the reason TestNG framewrok is used with Selenium WebDriver.
But have you wondered where to define the test suites and grouping of test classes in TestNG?
It is by taking instructions from the testng.xml file. We cannot define a test suite in testing source code, instead it is represented in an XML file, because suite is the feature of execution. The test suite is basically a collection of test cases.
So for executing the test cases in a suite, i.e a group of test cases, you have to create a testng.xml file which contains the name of all the classes and methods that you want to execute as a part of that execution flow.
Other advantages of using testng.xml file are:
- It allows execution of multiple test cases from multiple classes
- It allows parallel execution
- It allows execution of test cases in groups, where a single test can belong to multiple groups