然而,另一个ANT + JUnit的类路径问题 [英] Yet another Ant + JUnit classpath problem

查看:195
本文介绍了然而,另一个ANT + JUnit的类路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用Eclipse Eclipse的SWT应用程序。也有一些JUnit 4测试,其中测试一些DAO的。但是,当我尝试通过一个Ant构建运行测试,所有测试失败,因为测试类都没有找到。

I'm developing an Eclipse SWT application using Eclipse. There are also some JUnit 4 tests, which test some DAO's. But when I try to run the tests via an ant build, all of the tests fail, because the test classes aren't found.

谷歌提出了有关的人谁都有同样的问题一万美元,但没有他们的解决方案似乎为我-.-工作。

Google brought up about a million of people who all have the same problem, but none of their solutions seem to work for me -.- .

这是我的build.xml文件的内容:

These are the contents of my build.xml file:

<property name="test.reports" value="./test/reports" />
<property name="classes" value="build" />


<path id="project.classpath">
    <pathelement location="${classes}" />
</path>

<target name="testreport">
    <mkdir dir="${test.reports}" />
    <junit fork="yes" printsummary="no" haltonfailure="no">
        <batchtest fork="yes" todir="${test.reports}" >
            <fileset dir="${classes}">
                <include name="**/Test*.class" />
            </fileset>
        </batchtest>
        <formatter type="xml" />

        <classpath refid="project.classpath" />


    </junit>

    <junitreport todir="${test.reports}">
        <fileset dir="${test.reports}">
            <include name="TEST-*.xml" />
        </fileset>
        <report todir="${test.reports}" />
    </junitreport>
</target>

的测试类是在与应用程序的类的生成的目录一起,尽管它们在某些子根据其包

The test classes are in the build-directory together with the application classes, although they are in some subfolders according to their packages.

也许这也很重要:首先蚂蚁抱怨的JUnit是不是在它的类路径,但因为我把它放在那里(与Eclipse配置编辑器),它抱怨的JUnit在其类路径的两倍

Maybe this is important too: At first Ant complained that JUnit wasn't in its classpath, but since I put it there (with the eclipse configuration editor) it complains about JUnit being in its classpath twice.

WARNING: multiple versions of ant detected in path for junit 
   [junit]          jar:file:C:/Users/as df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class
   [junit]      and jar:file:/C:/Users/as%20df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class

我试过,指定每一个子目录,每一个类文件,我已经试过文件集的文件列表及,似乎没有任何工作。

I've tried specifying each and every subdirectory, each and every class file, I've tried filesets and filelists, nothing seems to work.

您的帮助谢谢,我已经坐了好几个小时在这件事上,现在...

Thanks for your help, I've been sitting for hours on this thing now...

推荐答案

我有同样的问题,在JUnit的路径检测蚂蚁多个版本。该问题就走了,当我改名由ECLIPSE_HOME目录,并从它删除特殊字符。该路为[1]它这是造成问题的原因。

I had the same problem 'multiple versions of ant detected in path for junit'. The problem went away when I renamed by Eclipse_Home directory and removed special characters from it. The path had '[1]' in it which was causing the problem.

这篇关于然而,另一个ANT + JUnit的类路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆