Posted on 18 Comments

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.

 

18 thoughts on “the import org.junit cannot be resolved in Eclipse

  1. Thanks Lahman, Its worked.

  2. thank u very much, it worked

  3. Thanks its worked!!!

  4. Thanks, super helpful

  5. This is really helpful. Thanks !!!

  6. very thankful

  7. Thanks a million!!!!

  8. Thanks a lot

  9. Thank you!

  10. Thank you

  11. Thanks it helpded!

  12. Thanks a bunch!

  13. Thanks ..that really helped!

  14. thank you! it helped me sooo much!!

  15. 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

    1. Thank you! It really helps me!

  16. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

HTML tags are not allowed.

174,075 Spambots Blocked by Simple Comments