TestNG Annotation AttributesTestNG Parameters are the arguments that we pass to the test methods. There are two ways through which we can pass the parameters to the test methods:
In this topic, we will learn about the TestNG Parameters. We will learn about the parameterization in the xml file. Suppose we want to set the global variables such url settings, username, password or API Keys, there are some values which are constant in all the test cases, in such case we use the TestNG Parameters. TestNG Parameters are present in the xml file. They can be applied either inside the Let's understand through an example. First case: When Parameters are applied below the Step 1: Open the Eclipse. Step 2: We create three class files, i.e., Sum.java, Subtract.java, and Multiply.java. Sum.java Subtract.java Multiply.java Step 3: Now, we create the testng.xml file. testng.xml In the above testng.xml file, we pass the parameters which are valid to all the classes. Step 4: Run the testng.xml file. Output ![]() Second case: When parameters are Step 1: Open the Eclipse. Step 2: We create two class files. i.e., Fruits.java and Vegetable.java. Fruits.java Vegetable.java Step 3: Now, we create the testng.xml file. In the above testng.xml, we specify the parameters in a particular Step 4: Run the testng.xml file. Output ![]()
Next TopicTestNG Listeners
|