ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: Accessing Properties from Sub-Projects
Date Wed, 03 Oct 2007 08:26:51 GMT
Christoph Krammer wrote:
> Hello everybody,
> I use Ant together with a Test framework for Web applications (Canoo
> WebTest). The main structure of the Ant files is the following:
> main build.xml:
> <project name="example" default="wt.deployToTest">
> 	<property name="webtest.home" value="C:\eclipse\webtest-2.5"/>	
> 	<import file="${webtest.home}/webtest.xml" />
> 	<property name="wt.testInWork" value="tests/jsfTest.xml"/>
> 	<target name="wt.deployToTest" depends="wt.full">
> 		<property file="tests/error.tmp" />
> 		<echo message="Test failure is: ${test.failure}" />
> 	</target>
> </project>
> Excerpt from the webtest.xml:
> ...
> <target name="wt.testInWork">
> 	<ant dir="${wt.testInWork.dir}" antfile="${wt.testInWork.file}"
> 		inheritRefs="true"/>
> </target>
> ...
> Excerpt from tests/jsfTest.xml:
> <project name="demo" default="test">
> 	<target name="test">
> 		<webtest name="Check if result contains name">
> 			...
> 		</webtest>
> 		<echo>
> 			test.failure: ${test.failure}
> 		</echo>
> 	</target>
> </project>
> If the test fails, the ${test.failure} property is set within the project in
> the jsfTest.xml file. But the problem is that I need the value of this
> property in the main build.xml file, since I want to decide further actions
> on basis of this value after all tests have been run.

  the ant-contrib extensions on sourceforge have a task to get results back

> I know one simple solution: To export the test.failure property to a file
> and read it in the build.xml. But this solution has one major drawback: The
> final test suite will consist of lots of webtest projects in different xml
> files (one per developer). The problem is to ensure that the test.failure
> value is exported in all files, in each single test's xml. If any one
> developer omits the export, a failure of his tests will not be taken into
> account for further decisions (like deployment to a productive system).
> Obviously, this is not perfect.

No, it isnt

1. you should have a common build file that is pulled in to the main 
file with <import>; it can do the result output

2. you can create a test.failed file for every project 
(build/results/tests.${}.failed) if -and only  if- the 
tests for that project failed.

3. then, the toplevel file uses <available> to look for any file 
matching that pattern, which implies that the test failed.


Steve Loughran        
Author: Ant in Action 

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

View raw message