Why is assertEquals(double,double) deprecated in JUnit?

后端 未结 4 1999
醉话见心
醉话见心 2020-12-05 03:46

I was wondering why assertEquals(double, double) is deprecated.

I used import static org.junit.Assert.assertEquals; and I used JUnit 4.11.<

4条回答
  •  醉酒成梦
    2020-12-05 04:29

    Old question but this hasn't been said yet and might help someone.

    You can use com.google.common.math.DoubleMath.fuzzyEquals(double a, double b, double tolerance) which allows you to specify how close the two doubles should be to each other.

    I found it very handy for unit tests where I don't want to hardcode test result values with a lot of decimal places.

提交回复
热议问题