2011-05-23 60 views

回答

4

事實上,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> 
+0

我知道我可以指定junit.jar的路徑,但這些選項都不允許我將文件重命名爲junit-4.8.2.jar。 – 2011-05-23 20:35:12

+0

' /path/to/junit-4.8.2.jar' – 2011-05-23 20:46:29

+0

哦,我現在看到了。我有點緊張,但文檔可能更明確一點,junit jar可以被稱爲除junit.jar之外的東西。 – 2011-05-24 13:27:13