Importance of testng.xml file

In a Selenium TestNG project, we use testng.xml file to configure the complete test suite in a single file. Some of the features are as follows.
  • testng.xml file allows to include or exclude the execution of test methods and test groups
  • It allows to pass parameters to the test cases
  • Allows to add group dependencies
  • Allows to add priorities to the test cases
  • Allows to configure parallel execution of test cases
  • Allows to parameterize the test cases
7. How to pass parameter through testng.xml file to a test case?
We could define the parameters in the testng.xml file and then reference those parameters in the source files.
Create a java test class, say, ParameterizedTest.java and add a test method say parameterizedTest() to the test class. This method takes a string as input parameter. Add the annotation @Parameters(“browser”) to this method.
The parameter would be passed a value from testng.xml, which we will see in the next step.
We could set the parameter using the below syntax in the testng.xml file. 
Here, name attribute represents the parameter name and value represents the value of that parameter.

Comments

  1. Great post buddy,

    Selenium
    is an open-source, test automation tool that has become an important automation tool in the software quality assurance world. This selenium testing tool consists of a different set of tools which include Selenium WebDriver, Selenium RC, Selenium IDE, and Selenium Grid, all of which have different features.

    ReplyDelete

Post a Comment

Popular posts from this blog

Handling Dynamic Web Tables Using Selenium WebDriver

Verify Specific Position of an Element

Read it out for TESTNG before going for an iterview