У меня есть файл build.xml, который позволяет запускать тесты junit. Вот соответствующая часть:
<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>
Если я заменю строку:
<pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
с
<pathelement location="${eclipse.home}/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
Изменение разбивает путь к классам. Я получаю следующую ошибку:
<classpath>
для<junit>
должен включить junit.jar, если не в Ant собственный Путь к классам
Насколько я понимаю, атрибут location должен иметь одинаковое значение в обоих случаях. Так в чем же причина?
В качестве побочного вопроса этот файл сборки не будет работать в среде с другой версией junit (путь будет разорван). Можно ли добавить "общий" путь к junit.jar?