You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Spencer Marks <sm...@digisolutions.com> on 2001/05/05 03:57:27 UTC
Exporting System.properites values
Hi,
I was wondering if there's a way to get Ant to set properties that would
then be available when a taskdef runs.
For example, before running JUnit tests, I'd like to pass a system
property specifying where test data is located. Then the JUnit test
would know where to access installation specific data.
Perhaps this is not the not best way to solve the problem. If not, I'd
like to hear how people solve similar problems.
Thanks, Spencer
Re: Exporting System.properites values
Posted by Spencer Marks <sm...@digisolutions.com>.
Hi,
Thanks for your help.
Would you mind tell me what's wrong with this snippet:
First, the error message:
/Users/sam/devo/projects/innoverity/RuleMaker/build.xml:144: Class
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask doesn't support
the nested "sysproperty" element
Here's how I am trying use it:
<target name = "junit">
<available property = "junit.properties" classname =
"junit.framework.TestCase"/>
</target>
<target name = "compiletests" depends = "compile">
<mkdir dir = "${build.tests}"/>
<javac srcdir = "${test.dir}" destdir = "${build.tests}">
<include name = "**/*JUnit*.java"/>
<!-- include the build.dir so we can run the tests -->
<classpath>
<fileset dir="./lib">
<include name="**/*.jar" />
</fileset>
<pathelement path = "${build.dir}/classes"/>
</classpath>
</javac>
</target>
<target name = "tests" depends = "compiletests">
<junit printsummary = "yes" fork = "no" haltonfailure =
"no">
<formatter type = "plain" usefile="false"/>
<sysproperty key="testdata.negative0" value="spencer"/>
<classpath>
<pathelement location = "${test.dir}"/>
<pathelement location = "${src.dir}"/>
<pathelement path = "${java.class.path}"/>
<pathelement path = "${build.tests}"/>
<pathelement path = "${build.dest}"/>
<fileset dir="./lib">
<include name="**/*.jar" />
</fileset>
<pathelement path = "${build.dir}/classes"/>
</classpath>
<batchtest fork = "yes">
<fileset dir = "${test.dir}">
<include name = "**/*JUnit*.java"/>
<exclude name = "**/AllTests.java"/>
</fileset>
</batchtest>
</junit>
</target>
Thanks, Spencer
On Saturday, May 5, 2001, at 03:58 PM, Robert Leftwich wrote:
> <sysproperty key="conf.dir" value="${unit.test.conf}"/>
> <sysproperty key="log4j.configuration"
> value="file:${unit.test.conf}/log4j.properties"/>
Re: Exporting System.properites values
Posted by Robert Leftwich <di...@ix.net.au>.
At 09:57 PM 04-05-01 -0400, Spencer Marks wrote:
>Hi,
>
>I was wondering if there's a way to get Ant to set properties that would
>then be available when a taskdef runs.
>
>For example, before running JUnit tests, I'd like to pass a system
>property specifying where test data is located. Then the JUnit test would
>know where to access installation specific data.
The junit task supports the sysproperty element which allows you to do
this, e.g.
<junit printsummary="yes" haltonfailure="no" fork="yes"
dir="${unit.test.dir}">
<sysproperty key="conf.dir" value="${unit.test.conf}"/>
<sysproperty key="log4j.configuration"
value="file:${unit.test.conf}/log4j.properties"/>
...
</junit>
HTH
Robert