运行 ant build 给出“包 org.junit 不存在"; [英] Running ant build gives "package org.junit does not exist"

查看:44
本文介绍了运行 ant build 给出“包 org.junit 不存在";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 Java IDE 构建具有 JUnit 测试的项目(例如 NetBeans)时,它们可以正常编译,但是当我尝试在 IDE 之外使用 ant 来运行构建脚本时,出现错误package org.junit 不存在".

When I use a Java IDE to build projects (e.g. NetBeans) that have JUnit tests, they compile fine, but when I try to use ant outside of the IDE to run the build script, I get the error "package org.junit does not exist".

推荐答案

您应该将 junit.jar 添加到 ant 文件的类路径定义中.

You should add your junit.jar into the classpath definition in your ant file.

有很多方法可以做到,一个例子是:

There are many way to do it, one example is:

<junit printsummary="yes" haltonfailure="yes">
    <classpath>
        <path refid="your.classpath.refid" />
        <fileset dir="${junit.dir}">
            <include name="**/junit.jar" />
        </fileset>
    </classpath>
    ...
</junit>

有关设置类路径的详细信息,请参阅 Ant 手册.

See Ant Manual for details on setting up your classpath.

这篇关于运行 ant build 给出“包 org.junit 不存在";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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