Why is assertEquals(double,double) no longer deprecated in JUnit 5?
Asked
Active
Viewed 171 times
0
-
It seems that your problem like [this ](https://stackoverflow.com/questions/33274030/why-is-assertequalsdouble-double-deprecated-in-junit/33274179#33274179) – Nguyễn Văn Phong Dec 10 '19 at 03:19
-
The question asked by 33274030 is "why is it deprecated?" In JUnit 5 it is **no longer** deprecated. My question is "why is it no longer deprecated?" – Jack Straub Dec 10 '19 at 04:54
-
Interestingly enough, the GitHub issues where this is discussed make no mention of the fact that it was deprecated in JUnit 4. See https://github.com/junit-team/junit5/issues/1606 and https://github.com/junit-team/junit5/pull/187 – kaya3 Dec 11 '19 at 22:18
1 Answers
1
Jupiter has both, an assert method to compare two doubles exactly and one to compare them with a given delta. You usually want the latter if any kind of calculation is involved that might come with rounding errors. Sometimes, however, you want to make sure that a calculation has an exact result; that’s when ˋassertEquals(double, double)ˋ comes in handy.
The danger of having this method is that people might confuse the two use cases and use exact comparison when delta comparison would be the better choice. The designers of JUnit 4 considered that risk to be dangerous enough to steer users away from it. The devs of Jupiter made a different judgement call.

johanneslink
- 4,877
- 1
- 20
- 37