Issue
package Jut;
import org.junit.*;
import static org.junit.Assert.*;
public class JUTest {
@Test
public void testDoubleComparison() {
double expected = 10.20;
double actual = 10.20;
assertEquals(expected, actual, 0.0);
}
}
Test Run says: No test passed, 1 test failed: The test case is a prototype. (junit.framework.AssertionFailedError)
But I'm sure this will works fine. Why it doesn't passed? I'm using Netbeans and the newest Junit (I think 4.10?).
Solution
"assertEquals" fails because the values are double
You can try using some value > 0 for epsilon
assertEquals(double expected, double actual, double epsilon)
So that will assert to true as long as Math.abs(expected - actual) < epsilon
Answered By - v.coder
Answer Checked By - David Goodson (JavaFixing Volunteer)