我目前面临的问题是我的单元测试在 eclipse 运行时通过,但在 maven 运行时失败。
这是存储库(+ pom.xml): https://github.com/thorstenwagner/ij-trajectory-classifier
这是构建日志: https://travis-ci.org/thorstenwagner/ij-trajectory-classifier
这是 mvn -v 的输出:
Apache Maven 3.3.9 (NON-CANONICAL_2015-11-23T13:17:27+03:00_root; 2015-11- 23T11:17:27+01:00)
Maven home: /opt/maven
Java version: 1.8.0_92, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "4.6.3-1-arch", arch: "amd64", family: "unix"
我曾尝试将我的 Java 版本从 1.7 更改为 1.6,但这没有帮助。
我很感激任何建议
最好的, 托斯滕
最佳答案
正如 Anton Koscejev 在评论中发表的那样:
默认情况下,Java 断言在 eclipse 中禁用,但在 maven 中默认启用。我添加了 <enableAssertions>false</enableAssertions>
到我的 pom.xml 并且它有效:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<reuseForks>false</reuseForks>
<forkCount>1</forkCount>
<enableAssertions>false</enableAssertions>
</configuration>
</plugin>
关于java - 单元测试仅在由 maven 运行时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38217401/