开发者

Refering a Parameter to another Parameter in testng.xml file

I have the following in testng.xml

...
<parameter name="Empl_Name" value="Stephen" />
<test name="Employee Search test" junit="false">
    <parameter name="Valid_Empl_Name" value="${Empl_Name}" />
    <classes> 
          <class name="org.EmployeeClass" />
    </classes> 
</test>

The above is not working. My requirement is that I want to refer the Parameter Valid_Empl_Name with the above mentioned Empl_Name. I want to reuse the Empl_Name parameter value in many of the test cases.

开发者_StackOverflowIs there any way to do this ?


This is currently not supported in TestNG but I'd be open to adding it.


Yes, its quite complex, but there is a way. If you build your project with Maven, there is a Maven plugin called build-helper-maven-plugin that will let you pre-process the .xml file before the build starts.

I did this in this project, but you can probably find better examples elsewhere. Maven is no longer favored over Gradle anyways; maybe you can do the same thing with Gradle (or Groovy script).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜