2011-05-23 57 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