Warm tip: This article is reproduced from stackoverflow.com, please click
cucumber java selenium testng

How to pass parameter to testng xml through command line

发布于 2020-04-23 16:37:14

I am executing my selenium automation scripts through testng, for the same I am having a testng xml form where I am passing parameter values like which test case has to be executed and on which environment it has to be executed.

E.g of testng xml is pasted below

**<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Automation Suite">
<parameter name="tags" value="MyTestCase"/>
    <!-- Default suite -->    
<test name="GGGGG Automation Test" verbose="2">
<parameter name="Environment" value="MyEnvironment" />
<classes>
<class name="com.XXXXX.TestRunner.XXXXXX"/>
   </classes>
 </test>  
</suite>**

here I am passing 2 parameters like test cases and environment to be executed form testng example. I am looking for a command line 'command' to execute the testng xml passing those 2 parameters from commandline argument.

Questioner
Shyam
Viewed
71
Kidby 2020-02-12 03:42

By using JVM arguments you can pass in parameters, such as -Dname=Environment. This has been answered previously here.

This blog post has examples