One JVMArg for only one JVM option?

1,005 views
Skip to first unread message

BK Lau

unread,
Nov 1, 2006, 6:26:57 PM11/1/06
to testng...@googlegroups.com
Hi folks:

I use Ant to run TestNG like this:
[b]Format#1[/b]
[i]<testng >
...
<jvmarg>-Dprop1=value1</jvmarg>
<jvmarg>-Dprop2=value2</jvmarg>
...
</testng>[/i]
This works.

But if I changed above to
[b]Format#2:[/b]

[i]<testng >
...
<jvmarg>-Dprop1=value1 -Dprop2=value2</jvmarg>
....
</testng>[/i]
It doesn't seems to work now; in particular -Dprop2=value2 is not taking effect.

So my question is why?. Since java.exe is launched under the hood in commandline fashion
java.exe -Dprop1=value1 -Dprop2=value2,
my first guess is that it probably doesn't matter if the -Dprop1=value1 -Dprop2=value2 are entered as one single <jvmarg> or two <jvmarg>.

Obviously, from above it does seems to matter.

Am I missing something?.
I needed format#2 as I dynamically scan an xml configuration file we used here and
concenated all -Dprops=values together and attempt to pass them in as a
single <jvmarg>....<./jvmarg> to testng

Any insight or help appreciated.

-BK-
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=48774&messageID=98317#98317

Alexandru Popescu

unread,
Nov 1, 2006, 6:31:55 PM11/1/06
to testng...@googlegroups.com
Use <jvmarg line=""/>

./alex
--
.w( the_mindstorm )p.
TestNG co-founder
EclipseTestNG Creator

Cédric Beust ♔

unread,
Nov 1, 2006, 6:32:48 PM11/1/06
to testng...@googlegroups.com
It looks like whatever is included between <jvmarg> and </jvmarg> is passed as a single argument to the JVM (maybe it's automatically surrounded with double quotes?).

I can't say at the moment if it's a TestNG or ant behavior.  How do other ant tasks behave?

--
Cedric
--
Cédric

Alexandru Popescu

unread,
Nov 1, 2006, 6:41:56 PM11/1/06
to testng...@googlegroups.com
On 11/2/06, Cédric Beust ♔ <cbe...@google.com> wrote:
> It looks like whatever is included between <jvmarg> and </jvmarg> is passed
> as a single argument to the JVM (maybe it's automatically surrounded with
> double quotes?).
>
> I can't say at the moment if it's a TestNG or ant behavior. How do other
> ant tasks behave?
>

It is Ant default behavior. You can read more in the Manual: using.html#arg

./alex
--
.w( the_mindstorm )p.
TestNG co-founder
EclipseTestNG Creator

> --

BK Lau

unread,
Nov 1, 2006, 6:52:04 PM11/1/06
to testng...@googlegroups.com
>
> Use <jvmarg line=""/>

Alex's suggestion works !
I can see the single "-Dprop1=value1 -Dprop2=value2" split
into 2 separate arguments "-Dprop1=value1" and "-Dprop2=value2"

-BK-


>
> ./alex
> --
> .w( the_mindstorm )p.
> TestNG co-founder

http://forums.opensymphony.com/thread.jspa?threadID=48774&messageID=98324#98324

Steve Loughran

unread,
Nov 2, 2006, 3:35:18 AM11/2/06
to testng...@googlegroups.com
Generic ant rules
1. Any single <jvmarg> is passed down as a single argument to the ant
task, no splitting on spaces.

2. a line argument is split by spaces. This is not always what you
want, as the split takes place after property expansion. if value1 or
value2 have spaces in, you are hosed. This can be an insidious source
of bugs if a value is a path, as it may work on some users machines
and not on others, depending on their filesystem.

3. most tasks let you set jvm properties with the <sysproperty> element.

-S.

Reply all
Reply to author
Forward
0 new messages