Passing parameters through maven command line

8,935 views
Skip to first unread message

Aswathy Nair

unread,
Jun 11, 2016, 1:20:00 PM6/11/16
to testng-users
Hi,

I have defined a parameter in testng.xml. I want to override the value through maven command line.
<parameter name="environment.code" value="QA"/>

I tried by setting systemPropertyVariable in pom.xml

<artifactId>maven-surefire-plugin</artifactId>
<configuration>
  <systemPropertyVariables>
    <environment.code>QA</environment.code>
  </systemPropertyVariables>
 <suiteXmlFiles>
   <suiteXmlFile>testng.xml</suiteXmlFile>
 </suiteXmlFiles>

But when trying to run through command line maven, value is not getting overridden.

Can someone pls guide me in acheiving the same.


Thanks,

Aswathy Nair

Vimal Raj

unread,
Jun 12, 2016, 1:59:10 AM6/12/16
to testng-users
Hi Aswathy,

You can change your parameter like this:

<parameter name="environment.code" value="${test.env}" />

and you can remove the systemPropertyVariable in your pom.xml.
Then in you command line:

mvn clean test -Dtest.env=QA

This should work.

Thanks
Vimalraj

Aswathy

unread,
Jun 12, 2016, 3:10:51 AM6/12/16
to testng-users
Hi Vimal,

Thanks alot. 
I tried the same and it worked for me.

Regards,

Aswathy

Gim Nguyễn

unread,
Jul 14, 2020, 3:55:21 PM7/14/20
to testng-users
Thank you a lot

Vào 12:59:10 UTC+7 Chủ Nhật, ngày 12 tháng 6 năm 2016, Vimal Raj đã viết:
Reply all
Reply to author
Forward
0 new messages