<test name="Test1">
<parameter name="someParam" value="someValue" />
<parameter name="someOtherParam" value="someOtherValue" />
<parameter name="someParam2" value="someValue2" />
<classes>
<class name="temp.Temp">
<methods>
<include name="test1" />
</methods>
</class>
</classes>
</test>
<test name="Test2">
<classes>
<class name="temp.Temp">
<methods>
<include name="test2" />
</methods>
</class>
</classes>
</test>
<test name="Test1">
<parameter name="someParam" value="someValue" />
<parameter name="someOtherParam" value="someOtherValue" />
<classes>
<class name="temp.Temp">
<methods>
<include name="test1" />
</methods>
</class>
</classes>
</test>
<test name="Test2">
<parameter name="someParam2" value="someValue2" />
<classes>
<class name="temp.Temp">
<methods>
<include name="test2" />
</methods>
</class>
</classes>
</test>
Akshay,
It should work. Here’s a sample
package com.rationaleemotions.googleforums.params;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class TestClass {
@Test
@Parameters({"name", "age"})
public void testMethod(String name, int age) {
Reporter.log(name + " is " + age + " years old", true);
Assert.assertNotNull(name);
Assert.assertTrue(age > 0);
}
}
Suite file :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="1265_Suite" parallel="false" verbose="2">
<parameter name="name" value="Jack"/>
<test name="partOne" parallel="false" preserve-order="true">
<parameter name="age" value="25"/>
<classes>
<class name="com.rationaleemotions.googleforums.params.TestClass"/>
</classes>
</test>
<test name="partTwo" parallel="false" preserve-order="true">
<parameter name="age" value="30"/>
<parameter name="name" value="Jill"/>
<classes>
<class name="com.rationaleemotions.googleforums.params.TestClass"/>
</classes>
</test>
</suite>
Output
...
... TestNG 6.11 by Cédric Beust (ced...@beust.com)
...
Jack is 25 years old
Jill is 30 years old
===============================================
1265_Suite
Total tests run: 2, Failures: 0, Skips: 0
===============================================
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Akshay,
Thanks for clarifying your usecase. No AFAIK, I don’t think you can pass in <parameters> to <method> via a TestNG suite xml file.
That said and done, you can very well achieve that using a @DataProvider annotation. Compared to passing parameters via <parameters> tag, it’s a lot more flexible, doesn’t involve an elaborately built suite xml file and gives you the luxury of making your parameters more dynamic. Wouldn’t that work for you ?
package temp;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class Temp {
@Test()
@Parameters ({"param","methodSpecificParam"})
public void test(String key1, String key2) {
System.out.println(key1+" "+key2);
}
}
<test name="Test1">
<parameter name="param" value="globalValue" />
<classes>
<class name="temp.Temp">
<methods>
<parameter name="methodSpecificParam" value="methodSpecificValue"/>
<parameter name="param" value="overridenValue"/>
<include name="test1" />
</methods>
</class>
</classes>
</test>
overridenValue methodSpecificValue
<test <span style="font-size:10.0pt;font-family:&qu
Great. Thanks for sharing that information. To be honest, I wasn’t aware of that till now!
Glad that this resolves your query.