3
默認情況下JUnit jars在文件名中具有版本號,例如junit-4.8.2.jar。 The JUnit Ant Task只能查找junit.jar。是否可以根據標準命名約定來指定名稱?我想這樣做,因爲我想在我的本地maven存儲庫中引用庫。爲ant junit任務指定junit.jar的替代名稱
默認情況下JUnit jars在文件名中具有版本號,例如junit-4.8.2.jar。 The JUnit Ant Task只能查找junit.jar。是否可以根據標準命名約定來指定名稱?我想這樣做,因爲我想在我的本地maven存儲庫中引用庫。爲ant junit任務指定junit.jar的替代名稱
事實上,JUnit的任務文件給你幾個選擇:
Note: You must have junit.jar available. You can do one of:
Put both junit.jar and ant-junit.jar in ANT_HOME/lib.
Do not put either in ANT_HOME/lib, and instead include their locations in your CLASSPATH environment variable.
Add both JARs to your classpath using -lib.
Specify the locations of both JARs using a <classpath> element in a <taskdef> in the build file.
Leave ant-junit.jar in its default location in ANT_HOME/lib but include junit.jar in the <classpath> passed to <junit>. (since Ant 1.7)
編輯
這是你所需要的。
<junit
...
>
<classpath>
<pathelement location="/path/to/your/custom/junit-4.8.2.jar""/>
<path refid="your.other.classpath.dependencies" />
</classpath>
...
</junit>
我知道我可以指定junit.jar的路徑,但這些選項都不允許我將文件重命名爲junit-4.8.2.jar。 – 2011-05-23 20:35:12
' /path/to/junit-4.8.2.jar ' –
2011-05-23 20:46:29
哦,我現在看到了。我有點緊張,但文檔可能更明確一點,junit jar可以被稱爲除junit.jar之外的東西。 – 2011-05-24 13:27:13