When creating a Java project, or importing an existing Java project, that uses JUnit tests in Eclipse, you may run into the error message:
the import org.junit cannot be resolved
The error results when properly attempting to import JUnit with lines like the following:
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
The error occurs because the JUnit library has not been configured for the project, but can be resolved using the following steps.
1. Right click on the Java project and select Build Path > Configure Build Path.
2. Click Add Library.
3. Select JUnit, then click Next.
4. Now select the latest version of the JUnit library, then click Finish.
The error should now be resolved.