Ambiguous method call Both assertEquals(Object, Object) in Assert and assertEquals(double, double) in Assert match:

Your getScore() returns Double, not double. Therefore compiler is confused: Should it convert both arguments to Object, or if it should convert only the Double to double?

    double a = 2.0;
    Double b = 2.0;
    // assertEquals(a,b); // fails to compile
    // the compiler is confused whether to use
    assertEquals((Object) a,(Object) b); // OK
    // or
    assertEquals(a,(double) b); // OK

Anyway, I would set the method to return primitive type double.


If you specifically interested in using Assert.assertEquals(double, double) (the primitive version), try calling overridden method that allows deviation and setting allowed deviation to zero, like this:

assertEquals(2.5, person.getScore(), 0.0);

You might also want to have third parameter to be something other than zero if person.getScore() is allowed to be slightly different from 2.5. For example, if 2.500001 is acceptable, then your test becomes

assertEquals(2.5, person.getScore(), 0.000001);