Issue
I have a question about JUnit assertEquals
to test double
values. Reading the API doc I can see:
@Deprecated public static void assertEquals(double expected, double actual)
Deprecated. Use
assertEquals(double expected, double actual, double delta)
instead.
(Note: in older documentation versions, the delta parameter is called epsilon)
What does the delta
(or epsilon
) parameter mean?
Solution
Epsilon is the value that the 2 numbers can be off by. So it will assert to true as long as Math.abs(expected - actual) <= epsilon
Answered By - jberg
Answer Checked By - Candace Johnson (JavaFixing Volunteer)