我正在尝试弄清楚如何让 Travis CI 与我在 Github 上的小型 Java 库一起工作。
问题似乎是每当构建过程进入编译阶段时,它不会编译单元测试,因为它似乎找不到 JUnit jar 文件。当然,Ant 脚本在我自己的计算机上运行得很好,但我无法在 Travis 上获得正确的类路径。我怎么知道他们在哪里(甚至是否)安装了 JUnit?
这是我的 Ant 脚本:
<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
最后是构建输出的链接。您也可以通过单击构建图标来获取它。
https://travis-ci.org/The-Craw/PrimeFactorizer
最佳答案
您的类路径中需要 junit.jar。 (我认为它在您的语言环境机器上的 Ant 的 lib 目录中)。
你可以看看项目模板https://github.com/mplacona/java-junit-template-project
关于java - 使用 Ant Build 的 Travis CI,找不到 JUnit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18651161/