I agree that there is nothing obviously incorrect.  However, do you run unit
tests and acceptance tests at the same time?
If so then there is a potential problem that the script will run the unit
tests then the acceptance tests then check the properties.
I suggest that the <if><then> not be used, instead have the test target
depend on targets for unit test and acceptance test.  Each of the new tasks
should check the tests.* properties.  I do not use <if><then>.  Some would
argue that it should not be used in Ant.  Do you know if properties set in
<if><then> will be present to the parent?

The script would look something like this:

       <target name="test" description="Runmning unit tests"
depends="test-unit,test-acceptance">
       </target>

       <target name="test-unit" if="${unit.test}">
           <echo message="running unit tests for project ${module}" />

           <junit haltonfailure="no" haltonerror="no"
failureproperty="tests.failures" errorproperty="tests.errors">

               <classpath>
                   <path refid="classpath.test" />
            </classpath>

            <formatter type="brief" usefile="false" />

            <batchtest fork="yes">
                <fileset dir="${src.tests}">
                    <include name="**/*UnitTestCase.java" />
                </fileset>
            </batchtest>
            </junit>

            <fail if="tests.errors" message="Test errors!!!"  />
            <fail if="tests.failures"  message="Test failed!!!"/>

       </target>

       <target name="test-acceptance" if="${acceptance.test}">
           <echo message="running acceptence tests for ${module}" />

           <junit haltonfailure="no" haltonerror="no"
failureproperty="tests.failures" errorproperty="tests.errors">

               <classpath>
                <path refid="classpath.test" />
            </classpath>

            <formatter type="brief" usefile="false" />

            <batchtest fork="yes">
                <fileset dir="${src.tests}">
                    <include name="**/*AcceptenceTestCase.java" />
                </fileset>
            </batchtest>
            </junit>

            <fail if="tests.errors" message="Test errors!!!"  />
            <fail if="tests.failures"  message="Test failed!!!"/>

       </target>

Reply via email to