the import org.junit cannot be resolved in Eclipse

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.

 

3 Responses to the import org.junit cannot be resolved in Eclipse

  1. WB December 14, 2018 at 2:58 am #

    Hi Todd Lahman, when I follow your instructions I still could not solve the problem until I found out that I have to import the cucumber-junit.1.0.2.jar (in my case the system needs 1.0.2 version) files by myself. So before I do that I download the .jar file on https://mvnrepository.com/artifact/info.cukes/cucumber-junit/1.0.2
    After that go to Eclipse on Menu Project > Properties > Java Build Path > Libraries > Add External JARs > add the .jar files you have downloaded > Apply and Close.
    After doing that I got my problem solved.
    Maybe it can help someone who has the same problem with me :D

  2. Ciaran September 1, 2018 at 11:29 am #

    Thank you!

  3. Nick August 12, 2018 at 7:51 pm #

    Thanks!

Leave a Reply

HTML tags are not allowed.

142,315 Spambots Blocked by Simple Comments