Travis CI 使用 Ant 构建,未找到 JUnit [英] Travis CI With Ant Build, Not Finding JUnit

查看:28
本文介绍了Travis CI 使用 Ant 构建,未找到 JUnit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何让 Travis CI 与我在 Github 上的小型 Java 库一起工作.

I'm trying to figure out how to get Travis CI working with my little Java library on Github.

问题似乎是,无论何时构建过程进入编译阶段,它都不会编译单元测试,因为它似乎找不到 JUnit jar 文件.当然,Ant 脚本在我自己的计算机上运行得很好,但我无法在 Travis 上获得正确的类路径.我怎么知道他们在哪里(甚至是否)安装了 JUnit?

The problem seems to be that whenever the build process gets to the compilation stage, it won't compile the unit tests because it can't seem to find the JUnit jar file. Of course the Ant script works beautifully on my own computer, but I can't get the classpath right on Travis. How am I supposed to know where (or even if) they installed JUnit?

这是我的 Ant 脚本:

Here's my Ant script:

<project>
    <target name="test">
        <delete dir="build" />

        <mkdir dir="build" />
        <javac includeantruntime="false" srcdir="src" destdir="build" />
        <javac includeantruntime="false" srcdir="tests" destdir="build" classpath="/usr/share/java/junit.jar" />

        <junit printsummary="on">
            <classpath>
                <pathelement location="build" />
                <pathelement path="/usr/share/java" />
            </classpath>
            <test name="FactorizeTest" />
        </junit>
    </target>
</project>

这是项目链接,注意漂亮的构建失败"图标.耶.
https://github.com/The-Craw/PrimeFactorizer

Here's the project link, notice the pretty "build failing" icon. Yay.
https://github.com/The-Craw/PrimeFactorizer

最后是构建输出的链接.您也可以通过单击构建图标来获取此信息.
https://travis-ci.org/The-Craw/PrimeFactorizer

And finally here's the link to the build output. You can also get this from clicking the build icon.
https://travis-ci.org/The-Craw/PrimeFactorizer

推荐答案

您的类路径中需要 junit.jar.(我认为这是在您的语言环境机器上 Ant 的 lib 目录中).

You need the junit.jar on your classpath. (I think that is in Ant's lib directory on your locale machine).

你可以看看项目模板 https://github.com/mlacona/java-junit-template-project

这篇关于Travis CI 使用 Ant 构建,未找到 JUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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