Art*_*ium 16 java eclipse ant junit
我有一个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>
Run Code Online (Sandbox Code Playgroud)
如果我更换线路:
<pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
Run Code Online (Sandbox Code Playgroud)
同
<pathelement location="${eclipse.home}/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
Run Code Online (Sandbox Code Playgroud)
更改打破了类路径.我收到以下错误:
该
<classpath>用于<junit>如果不是在Ant的自己的类路径必须包含的junit.jar
据我所知,location属性在两种情况下都应该保持相同的值.那可能是什么原因呢?
作为一个附带问题,此构建文件不适用于具有不同junit版本的环境(路径将中断).是否可以为junit.jar添加"常规"路径?