O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – passing parameter values

Perform the following steps to pass parameter values:

  1. Open the previously created Java project.
  2. Create a new class named ParametrizedTest under the test.sample package and add the following code to it:
    package test.sample; import org.testng.annotations.Parameters; import org.testng.annotations.Test; public class ParametrizedTest { @Parameters({"suite-param-one","test-param-one"}) @Test public void paramTestOne(String suiteParam,String testParam){ System.out.println("Test One."); System.out.println("Suite param is: "+suiteParam); System.out.println("Test param is: "+testParam); } @Parameters({"suite-param-two","test-param-two"}) @Test public void paramTestTwo(String suiteParam,String testParam){ System.out.println("Test ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required