javadba javadba - 7 months ago 55
Java Question

How to test for equality of float/double in JUnit?


method is justifiably deprecated. Is there an alternate and/or different approach baked into junit - or do I roll my own tiny extension

static boolean assertEquals(double d1, double d2) {
return Math.abs(d1 - d2) < 1e-8;


Yes, use assertEquals(double expected, double actual, double delta) instead.