Parameters to provide data to a testng test

DataProvider is used to provide data to a test case.

Parameter can be used to provide a single value or a few values to a test case using xml. It is very rarely used. We mostly provide values to testng using properties file or dataproviders

Example for providing values using parameters in below.

We provide the branch name value to the test using parameter

public class BankTest {
   @Test
   @Parameters("branchName")
   public void parameterTest(String branchName) {
      System.out.println("The name of the branch is  : " + branchName);
   }
}

And we provide the branch name value in testng.xml as below

<?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 = "branchName" value="Downtown Toronto"/>

      <classes>
         <class name = "BankTest" />
      </classes>

   </test>
</suite>