简体   繁体   中英

Unit tests only fail when run by maven

I'm currently facing the problem that my unit tests are passing when run by eclipse but failing when run by maven.

This is the repository (+ pom.xml): https://github.com/thorstenwagner/ij-trajectory-classifier

Here is the build log: https://travis-ci.org/thorstenwagner/ij-trajectory-classifier

This is the output of 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"

I've tried to change my java version from 1.7 to 1.6 but this didn't help.

I appreciate any suggestions

Best, Thorsten

As posted by Anton Koscejev in the comments: Java assertions are disabled in eclipse by default but enabled in maven by default. I've added <enableAssertions>false</enableAssertions> to my pom.xml and it works:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM