如何使用maven从命令行将参数传递到testng.xml [英] how to pass parameter to testng.xml from command line with maven

查看:615
本文介绍了如何使用maven从命令行将参数传递到testng.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用testng运行Appium测试 想要将应用程序路径传递给所需功能作为testng.xml文件的参数 我如何从命令行使用maven做到这一点?

I am running appium test using testng want to pass app path to desired capabilities as parameter to testng.xml file how 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆