Parameters from testng.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Parameters from testng.xml

Eeshwar
This post has NOT been accepted by the mailing list yet.
Hi,

I am trying to pass parameters from testing.xml , I used simple number to print .
Here is my code used :

Testng.xml:

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">
  <test name="Test">
  <parameter name="test" value="2"/>
    <classes>
      <class name="testng.ParameterTest"/>
    </classes>
  </test> 
</suite> 


ParemeterTest.java:

package testng;

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


public class ParameterTest {

        @Parameters({"test"})
        @Test
        public void parameterIntTest(@Optional(1) int number) {
           System.out.println("Parameterized Number is : " + number);
        }

}


I have tried running m testing.xml file as TESTNG , as my test.java is not working. But still I can not execute this, as I am using @Optional vale=1 , it is printing result as "1" , but I want to pass parameter from xml file and my output should be 2. I searched all and wrote exactly shown as in TestNG documentation, but I do Not where I am missing ,

Please help me in solving this issue