xmlparameterstestngsuite

Is there a way to specify parameters for included methods in TestNG suite.xml?


I'm writing a suite.xml for an own testframework based on TestNG. My xml file looks like:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite" parallel="methods">
  <test name="NewTest">
  <parameter name="BROWSER" value="Chrome"></parameter>
  <classes>
   <class name="hm.NewTest">
     <methods>
        <include name="test"></include>
        <include name="test2"></include>
        <include name="test3"></include>
        <include name="test4"></include>
     </methods>
   </class>
 </classes>
 </test>
 </suite>

The parameter "BROWSER" is now specified for the complete test. But i need an own parameter for each of the included methods. Does anyone knows a solution?


Solution

  • For this rather than assigning parameters in test suite xml you can assign parameters for your tests individually . for that you don't have to add each parameter in suite.xml .

    @Parameters({ "datasource", "jdbcDriver" })
    @test
    public void sampleTest(String ds, String driver) {
    // your test method
    }
    

    Hope this will help you 1

    http://testng.org/doc/documentation-main.html#parameters