How can we pass the parameter to the test script using TestNG?

How can we pass the parameter to the test script using TestNG?

Using @Parameter annotation and the ‘parameter’ tag in testng.xml we can pass parameters to the test script. Sample testng.xml –

Sample test script-

public class TestFile { @Test @Parameters(“sampleParamName”) public void parameterTest(String paramValue) { System.out.println("Value of sampleParamName is - " + sampleParamName); }