ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <>
Subject Re: Ant not passing System values to JUnit task
Date Tue, 02 Dec 2003 17:24:34 GMT
Your build script did not come thu.

  setting -Dx=y on the ant.bat or ant shell script does *not* set a 
system property.
  It sets an ant property.

  To set the system property in the for the <junit> task, you need to
  use the nested element <sysproperty>.

  <sysproperty key="active.level" value="${active.level}"/>
  <test name="my.test.TestCase"/>


Dubois, Jeff wrote:

>When doing an Ant build of my project (see attached myBuild.xml script) It
>appears that ant is not passing System variables/values when executing the
>JUnit task.  I am on Windows using Ant 1.5.3.
>For my JUnit test cases to succeed I need a VM/System variable called
>"active.level" set to "dev"..  When executing Ant (via a batch file) I pass
>in the value of "active.level" via a "-Dactive.level=dev" argument on the
>command line.
>In my ant script I echo out the value of "active.level" and indeed it is set
>to "dev" (see runUnitTest target in attached script).
>However, when I run the Unit test, this "active.level" variable is no longer
>set.  I verified this by printing out the value of "active.level" in one of
>the Java test cases that get run.
>    The code I use is:
>           System.out.println( "active.level is: " +
>The corresponding output when run through ant is:
>          [junit] active.level is: null
>By default are not all System variables supposed to be passed to the JUnit
>    Jeff
> <<myBuild.xml>> 
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message