Posted on 3 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.

 

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

  1. 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. Thank you!

Leave a Reply

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

HTML tags are not allowed.

143,421 Spambots Blocked by Simple Comments