I have the an build.xml that allows me to run junit tests. Here is the relevant part:
<path id="JUnit 4.libraryclasspath">
<pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
<pathelement location="../../../../../eclipse/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
</path>
<path id="MyProject.classpath">
<pathelement location="bin"/>
<path refid="JUnit 4.libraryclasspath"/>
</path>
<target name="run_unit_tests" depends="build">
<mkdir dir="${junit.output.dir}"/>
<junit printsummary="yes" haltonfailure="no">
<classpath refid="MyProject.classpath" />
<formatter type="xml"/>
<batchtest todir="${junit.output.dir}">
<fileset dir="${src}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
If I replace the line:
<pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
with
<pathelement location="${eclipse.home}/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
The change breaks the classpath. I get the following error:
The
<classpath>
for<junit>
must include junit.jar if not in Ant's own classpath
As far as I understand, the location attribute should hold the same value in both cases. So what can be the reason?
As a side question, this build file will not work on an environment with different junit version (the path will break). Is it possible to add a "general" path to junit.jar?