Travis CI With Ant Build, Not Finding JUnit

喜夏-厌秋 提交于 2019-12-06 03:33:41

问题


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

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?

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>

Here's the project link, notice the pretty "build failing" icon. Yay.
https://github.com/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


回答1:


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

You may have a look at the project template https://github.com/mplacona/java-junit-template-project



来源:https://stackoverflow.com/questions/18651161/travis-ci-with-ant-build-not-finding-junit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!