问题描述
我正在使用testng运行Appium测试想要将应用程序路径传递给所需功能作为testng.xml文件的参数我如何从命令行使用maven做到这一点?
I am running appium test using testngwant to pass app path to desired capabilities as parameter to testng.xml filehow can i do this from command line with maven ?
推荐答案
假设您有一个如下所示的套件xml文件
Lets say you have a suite xml file which looks like below
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="sample_suite" verbose="1" parallel="false" thread-count="2">
<test name="sample_test">
<parameter name="name" value="Krishnan"/>
<classes>
<class name="ParameterisedSampleTestClass" />
</classes>
</test>
</suite>
您想将参数name
的值更改为除Krishnan
以外的其他值(这是套件xml文件中定义的值)
And you would like to change the value of the parameter name
to a different value other than Krishnan
(which is what is defined in the suite xml file)
您基本上是通过传递JVM参数-Dname=John
来实现的.
You basically do this by passing the JVM argument -Dname=John
.
默认情况下,TestNG支持更改参数值并在通过JVM参数运行时接受值.
TestNG by default supports changing parameter values and accepts values at run via JVM arguments.
对于JVM参数,您只需要使用与参数名称相同的名称即可.
You just need to use the same name as your parameter name, for the JVM argument.
您可以在我的博客文章此处找到更多详细信息
You can find more details in my blog post here
这篇关于如何使用maven从命令行将参数传递到testng.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!