Look for a warning that the compiler must be 5.0 compliant. Click on the link and change the compliance level to 5.0.
You should be back to the previous dialog box. Look for a warning that says JUnit 4 is not on the build path. Click on the "Click Here." This will should remove the warning and add JUnit 4 under Latitude project.
import org.junit.Test; // need to import for JUnit 4.0 import static org.junit.Assert.assertEquals; import org.junit.After; // need if use @After import org.junit.Before; // need if use @Before import org.junit.Ignore; // need if use @IgnoreOne would think Eclipse would add these for you. (?)
Note that Eclipse flags with a litle light bulb a warning that org.junit.After and orig.junit.Ignore are not used in this example.
private Latitude N0; private Latitude N90; // Done before any tests. Method name can be anything. @Before public void setUp1() { N0 = new Latitude(); N90 = new Latitude(90.0, 0.0, 0.0, "N"); } // Each method with tests needs @Test @Test public void testLatitudeConst() { // O degrees N from default constructor should equal // 0 degrees N from 4 arg constructor Latitude N0expected = new Latitude(0.0, 0.0, 0.0, "N"); // check if true with assert(); // Must have -ea option on java command or asserts are ignored. assert(N0.equals( N0expected)); // 0 degrees N should be equal to 0 degrees S. Latitude S0expected = new Latitude(0.0, 0.0, 0.0, "S"); // check if equals with assertEquals() assertEquals(N0, S0expected); }
Look below the JUnit report and find the Failure Trace. It will show the line in the source where the error was detected. If you double-click on this line, it will highlight that line in the source.