ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: Passing command line parameter to ant and reading them from w ithin JUnit
Date Thu, 13 Feb 2003 15:18:28 GMT
Just as a teaser, here's how I do it:

    <junitx ...>
      <classpath refid="classpath" />


        <propertyref prefix="testall." />
        <propertyref prefix="runtime-" />
        <mapper type="regexp" from="runtime-(.*)" to="\1" />


<junitx> simply extends <junit> to add the <syspropertyset> data type, which
is a little experiment I coded. The 3 classes in questions are included in
the zip. (Provided without any warranties; use this code at your own risk).

Note that this new feature was discussed earlier on the Ant forums, and I
just hacked at it. The code is neither well tested nor production quality,
but works for the limited use I make of it. --DD

-----Original Message-----
From: Jesse Stockall [] 
Sent: Wednesday, February 12, 2003 6:45 PM
To: Ant Users List
Subject: Re: Passing command line parameter to ant and reading them from
within JUnit

On Wednesday, February 12, 2003, at 07:31 PM, Tony Obermeit wrote:
> I would like to reference the property values passed
> on the command line to ant within Junit java code.  Is
> this possible?


If you run Ant like this:

ant -Dmyprop1=value1 -Dmyprop2=value2

Define your junit target like this:

	<sysproperty key="prop1" value="${myprop1}"/>
	<sysproperty key="prop2" value="${myprop2}"/>

Then in your testcases you can do System.getProperty("prop1");

Jesse Stockall -
CRYPTOCard Corp.

  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message