0
我们有一个Java项目以及我们打算在Linux平台上运行的相应的JUnit测试套件。它是使用Windows开发的,没有任何问题。Linux上的IntelliJ JUnit测试运行器和Gradle JUnit测试运行器之间的差异
在Linux上使用gradle test
运行我们的单元测试套件时,浮点差异开始出现。 IntelliJ测试跑步者和Gradle内置跑步者似乎也有区别。
JDK使用:孙JDK 1.8u91 64
Running tests using 'gradle test' on Linux: ERRORS (see below)
Running tests using IntelliJ test runner on Linux: OK
Running tests using 'gradle test' on Windows: OK
Running tests using IntelliJ test runner on Windows: OK
junit.framework.AssertionFailedError: expected:<-2.18> but was:<-2.1652631074322057>
junit.framework.AssertionFailedError: expected:<1.11> but was:<1.1376954128942385>
junit.framework.AssertionFailedError: expected:<373.32> but was:<375.4870142751794>
你能给出一个测试代码的示例代码片段吗?如果你想避免浮点问题,我建议你使用'java.math.BigDecimal' –