how to pass parameters using testng.xml

0 votes
I need to pass parameters using testng.xml. How do i do that?

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by (171 points)
0 votes
Best answer

You can pass parameters like this.


In class:

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class ParameterizedTest1 {
    public void parameterTest(String myName) {
        System.out.println("Parameterized value is : " + myName);

In testng.xml


<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
    <test name="test1">
	<parameter name="myName" value="manisha"/> 
	    <class name="ParameterizedTest1" />


commented by
Couldn't get this to work while passing multiple parameters.
commented by (171 points)
Try using {} for getting multiple parameters.