ant testall generates numerous unit test failures due to missing items in the classpath. I added the pathelement items as well as the junit report task after the junit task.
I'd recommend adding an antcall to testall in the "dist" target after "clean" and "package". We should always know if it passes unit tests.
<target name="testall" depends="build-unit-tests" unless="skip.tests"
description="Runs all unit tests"
>
<echo message="if the next task fails then please read the build script" />
<!-- if the next fails then here is the long answer:
http://ant.apache.org/faq.html#delegating-classloader
the short answer depends.
if you have Ant 1.7, the junit.jar can exist on the classpath.
upgrading to 1.7 may be the best solution.
if you have Ant 1.6:
ant -lib test/lib/junit.jar testall
if you have a version of Ant prior to 1.6 on Windows:
set CLASSPATH=%CLASSPATH%;test\lib\junit.jar
ant testall
if you have a version of Ant prior to 1.6 on UNIX:
export CLASSPATH=${CLASSPATH}:test/lib/junit.jar; ant testall
-->
<junit printsummary="on" errorproperty="error.junit">
<classpath>
<pathelement location="${freecol.build.dir}" />
<pathelement location="test/lib/junit.jar" />
<pathelement location="${basedir}/jars/higlayout.jar" />
<pathelement location="${basedir}/jars/jsr173_1.0_api.jar" />
<pathelement location="${basedir}/jars/wstx-lgpl-4.0pr1.jar"/>
</classpath>
<formatter type="xml" />
<batchtest fork="yes" todir="${freecol.build.dir}">
<fileset dir="test/src" includes="**/*Test.java" />
</batchtest>
</junit>
<delete dir="build/report" />
<mkdir dir="build/report"/>
<junitreport>
<fileset dir="build">
<include name="TEST-*.xml"/>
</fileset>
<report todir="build/report" />
</junitreport>
<fail if="error.junit">
Automated Unit Tests failed. See detailed report to debug.
</fail>
</target>
Logged In: YES
user_id=73455
Originator: NO
I see absolutely no difference when running the target with or without the additional pathelements.
Logged In: YES
user_id=1758816
Originator: YES
First change suggested: adding junit to the pathelement
Since ANT 1.7 (current release version), this prevents the following error. You've probably got the junit.jar in your system classpath, so this won't affect you, but for some users, this eliminates the issue that caused you to write the "read the source" echo task below. My suggestion to change this also changes that comment text.
testall:
[echo] if the next task fails then please read the build script
BUILD FAILED
/Users/michael/Projects/FreeCol/freecol/build.xml:363: The <classpath> for <junit> must include junit.jar if not in Ant's own classpath
Logged In: YES
user_id=1758816
Originator: YES
Second set of pathelement additions (taken from the compile target)
Again, if you already have these jars in your system classpath, this won't have a visible effect, but mirroring the classpath of the compile target makes it consistent and prevents someone from hunting errors in code that passes unit tests.
If this change is not made and the prerequisites are not already in your classpath:
testall:
[echo] if the next task fails then please read the build script
[junit] Running net.sf.freecol.common.SpecificationTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.311 sec
[junit] Running net.sf.freecol.common.model.ColonyProductionTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.052 sec
[junit] Test net.sf.freecol.common.model.ColonyProductionTest FAILED
[junit] Running net.sf.freecol.common.model.GameTest
[junit] Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.071 sec
[junit] Test net.sf.freecol.common.model.GameTest FAILED
[junit] Running net.sf.freecol.common.model.MapTest
[junit] Tests run: 7, Failures: 0, Errors: 7, Time elapsed: 0.096 sec
[junit] Test net.sf.freecol.common.model.MapTest FAILED
[junit] Running net.sf.freecol.common.model.TileTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.047 sec
[junit] Test net.sf.freecol.common.model.TileTest FAILED
[junit] Running net.sf.freecol.common.model.UnitTest
[junit] Tests run: 3, Failures: 0, Errors: 3, Time elapsed: 0.076 sec
[junit] Test net.sf.freecol.common.model.UnitTest FAILED
[junit] Running net.sf.freecol.server.generator.MapGeneratorTest
[junit] Tests run: 4, Failures: 0, Errors: 4, Time elapsed: 0.097 sec
[junit] Test net.sf.freecol.server.generator.MapGeneratorTest FAILED
Logged In: YES
user_id=1758816
Originator: YES
Adding junitreport and changing the formatter type to xml provide a more navigable way to see the entire test suite results and drill down to details.
Adding the errorproperty and fail if tasks provide the ability to fail the task if any of the junit tests fail.
Adding testall to the dist target gives anyone building distributions some confidence that the distribution actually passes the unit tests before rolling it up.
Logged In: YES
user_id=73455
Originator: NO
Look, why don't you just take the current build.xml from CVS, make all the changes you consider necessary or desirable and submit that new version?
Logged In: YES
user_id=1758816
Originator: YES
OK.
Sorry, I didn't mean to cause problems. The last project I worked on the maintainer didn't want anything that he hadn't really approved in advance.
Logged In: YES
user_id=717082
Originator: NO
Also, you can submit a patch, it's better than try to explain the changes.
Logged In: YES
user_id=73455
Originator: NO
Fixed by the reporter himself.