environment variables in testng.xml

5,157 views
Skip to first unread message

Ivan Delibashev

unread,
Jun 3, 2010, 9:51:19 AM6/3/10
to testng-users
Hi,

I am trying to use testng to execute tests automation server. Because
my test environment is dynamic i prefer not to hard-code it in
testng.xml.
For example i will execute tests against a server install on some
remote machine which can change.
Is there a way testng to be notified by testng.xml to look for system
environmet variables? In ant scripts this is done via "env.PATH"

Regards
Ivan

Cédric Beust ♔

unread,
Jun 3, 2010, 10:11:58 AM6/3/10
to testng...@googlegroups.com
Hi Ivan,

This is not supported at the moment but TestNG does see system properties as parameters, so you can achieve a similar result as follows:

java -Dpath=$PATH org.testng.TestNG testng.xml

and in your code:

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

--
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

Ivan Delibashev

unread,
Jun 4, 2010, 7:33:40 AM6/4/10
to testng-users
Hi Cedric,

Thanks for answer. I will implement it in way you suggest.

Regards
Ivan

On Jun 3, 5:11 pm, Cédric Beust ♔ <ced...@beust.com> wrote:
> Hi Ivan,
>
> This is not supported at the moment but TestNG does see system properties as
> parameters, so you can achieve a similar result as follows:
>
> java -Dpath=$PATH org.testng.TestNG testng.xml
>
> and in your code:
>
> @Parameters("path")
> @Test
> public void f(String path) {
>   ...
>
> }
>
> --
> Cédric
>
> On Thu, Jun 3, 2010 at 6:51 AM, Ivan Delibashev
> <ivan.delibas...@gmail.com>wrote:
>
>
>
>
>
> > Hi,
>
> > I am trying to use testng to execute tests automation server. Because
> > my test environment is dynamic i prefer not to hard-code it in
> > testng.xml.
> > For example i will execute tests against a server install on some
> > remote machine which can change.
> > Is there a way testng to be notified by testng.xml to look for system
> > environmet variables? In ant scripts this is done via "env.PATH"
>
> > Regards
> > Ivan
>
> > --
> > 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%2Bunsubscribe@google groups.com>
> > .
Reply all
Reply to author
Forward
0 new messages