The parameters in xml file are set inside the <include>
tag, something like this:
<suite name="Suite">
<listeners>
<listener class-name="..MyTestListener"/>
</listeners>
<classes>
<class name="Foo">
<methods>
<include name="myTest">
<parameter name="parameter1" value="parameterValue"/>
</include>
..
Of course I can reach the test parameter in beforeInvocation method if the parameter tag is outside of the include tag, example: method.getTestMethod().getXmlTest().getParameter("parameter1")
. But in this case parameter is necessary to be bound to the test method, and I get null as getParameter method return value.
Thanks, Stristi
I found the answer for my question. IInvokedMethodListener beforeInvocation method has ITestResult parameter, which has getParameters and setParameters methods. Or IHookable interface allows you to handle the input parameters of the testMethod, and call back the testMethod.
Br, Stristi
As per the dtd here, parameters can be defined at the <suite>
or at the <test>
level.
Parameters defined at the level override parameters of the same name in <suite>
. So, one cannot associate a parameter at class level.
Also, a <test>
in testng means a set of classes eg here. You can probably refer to the part of testng documentation, where testng xml nomenclature is explained, if it helps. The parameters in the <test>
tag, can be referred by all the classes that fall under it.