System Property visible to testng.xml?

2,449 views
Skip to first unread message

Grig

unread,
Jan 10, 2011, 10:24:22 AM1/10/11
to testng-users
I have a parameter in the testng.xml that I want the value to be
populated from the System Property.

<parameter name="esb-url" value="<SYSTEM_PROPERTY ESBURL>" />

Is this possible?

Mohamed Mansour

unread,
Jan 10, 2011, 12:58:14 PM1/10/11
to testng...@googlegroups.com
Hi Grig,

You can use ANT (or Maven), to replace those items. For example in ANT:

<target name="replace-esb-url">
   <property environment="env" />
   <property name="esburl" value="${env.ESBURL}" />
   <copy todir="." overwrite="yes">
     <fileset dir=".">
       <include name="testng.xml" />
     </fileset>
     <filterset>
       <filter token="ESBURL" value="${esburl}" />
       </filterset>
    </copy>
</target>

Then within your testng.xml, you can just use:

<parameter name="esb-url" value="%ESBURL%" />

The above is not tested, but hopefully it will help you out.

Kind regards,
Mohamed Mansour




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


Cédric Beust ♔

unread,
Jan 10, 2011, 1:09:29 PM1/10/11
to testng...@googlegroups.com
Hi Grig,

System properties are automatically exposed as TestNG parameters, so you should be able to use the system property directly in your class.

For example:

@Parameters("url")
@Test
public void f(String url) {
 ...
}

java -Durl="http://foo.com" org.testng.TestNG <your class>

-- 
Cédric


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric


Grig

unread,
Jan 10, 2011, 2:27:46 PM1/10/11
to testng-users
Thanks guys. Appreciate it.

On Jan 10, 12:09 pm, Cédric Beust ♔ <ced...@beust.com> wrote:
> Hi Grig,
>
> System properties are automatically exposed as TestNG parameters, so you
> should be able to use the system property directly in your class.
>
> For example:
>
> @Parameters("url")
> @Test
> public void f(String url) {
>  ...
>
> }
>
> java -Durl="http://foo.com" org.testng.TestNG <your class>
>
> --
> Cédric
>
>
>
> On Mon, Jan 10, 2011 at 7:24 AM, Grig <grig.w...@gmail.com> wrote:
> > I have a parameter in the testng.xml that I want the value to be
> > populated from the System Property.
>
> > <parameter name="esb-url" value="<SYSTEM_PROPERTY ESBURL>" />
>
> > Is this possible?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>
> > .

Dan Tran

unread,
Jul 18, 2015, 7:06:41 PM7/18/15
to testng...@googlegroups.com
Hi, 

From my attempt,  system properties cannot override the values set in testng.xml files

Please confirm

Thanks

-Dan
Reply all
Reply to author
Forward
0 new messages