Specifying "parameter" as parameter from command line.

88 views
Skip to first unread message

Tarun Bhadauria

unread,
Aug 14, 2011, 12:32:09 PM8/14/11
to testng...@googlegroups.com
I have a parameter - <parameter name="appURL" value="http://www.gutegutscheine.de/" />

Which is used for test execution.

1. Is it possible to have it passed from command line while using testng comnnad line execution? I noticed command line parameter and the one available with ant but could not find it.
2. Many of my classes use this parameter and I wonder if my classes would still be able to use it when specifying it from command line.

Thanks
Tarun K

Cédric Beust ♔

unread,
Aug 14, 2011, 12:49:18 PM8/14/11
to testng...@googlegroups.com
Yes, you can specify it as a system property to the JVM (java -Dparameter=value) and TestNG will turn it into a parameter.

-- 
Cédric




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/WwS5dqvFwmoJ.
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.

Tarun Bhadauria

unread,
Aug 16, 2011, 4:26:58 AM8/16/11
to testng...@googlegroups.com
Dumb question 1 -

I am using "ant" to execute tests, so I execute "run" target as -

ant run

Now I want to pass URL parameter from ant instead of testng,xml file, so I tried -

ant -Durl = "yahoo.com" run

And this results in test failure as my test method expecting "url" parameter can not access it. And I don't have "url" parameter defined in testng.xml file also...
Now how would I establish the correspondence b/w ant and testng test methods so that my test methods take the parameter which is passed from command line.

Thanks
Tarun K




Cédric Beust ♔

unread,
Aug 16, 2011, 5:04:14 PM8/16/11
to testng...@googlegroups.com
Are you specifying delegateCommandSystemProperties="true"?

    <testng outputdir="${testng.report.dir}"
        classpathref="run.cp"
        useDefaultListeners="true"
        delegateCommandSystemProperties="true"
        outputDir="${testng.report.dir}">
      <xmlfileset dir="${test.resources.dir}" includes="testng-single.xml"/>
     </testng>

-- 
Cédric





Thanks
Tarun K




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/mMfLSPnWVx0J.

Tarun Bhadauria

unread,
Aug 17, 2011, 2:25:08 AM8/17/11
to testng...@googlegroups.com
thank you, works best
Reply all
Reply to author
Forward
0 new messages