When it comes to Selenium test automation, running one test at a time will not be very beneficial. You will have to run multiple test cases to make the most of a Selenium Grid. In this tutorial, let’s dive deep into how we can execute multiple test files from a single file known as the TestNG XML file. We will also see how we can create and execute a parallel testing suite using a TestNG XML file.
What’s the purpose of a TestNG XML File?
The entire point of using a TestNG framework is to run tests in parallel, i.e. run multiple tests simultaneously. In Java, you have to create test cases separately and then define the test later in the primary method. On the other hand, TestNG allows you to create multiple test cases simultaneously, and that is where the TestNG XML file comes in. A TestNG XML file eases this task, and we can write various test cases all within single or multiple classes using annotations. (Refer: TestNG Annotations Tutorial for Selenium test automation)
Uses of TestNG XML file:
- Seamless parallel execution
- Executing multiple test cases for various Java class files
- Group execution of test cases
- Supports Parameterisation in TestNG and data-driven testing
- Including or excluding a particular test method
- Includes names of class, folders, and methods
- Clearer test summary with separate HTML and extent reports
- TestNG listeners automatically create logs