Unable to import mockito in Eclipse - disappeared immediately

11,611

I made a very silly mistake. The Junit test cases that I was writing were placed under src/main instead of src/test folder. Hence, even the dependency was added in the pom.xml file, it was saying it cannot be resolved. Just make sure your .java file for Junit test cases is under src/test/

Share:
11,611
Martin
Author by

Martin

Updated on July 14, 2022

Comments

  • Martin
    Martin almost 2 years

    I am trying to do a mock test of my code with mockito. In my POM.xml, the following dependency is stated as below.

    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
    </dependency>
    

    However, when I am trying to import the mockito as below, it disappeared immediately and I cannot do anything with it:

    import static org.mockito.Mockito.*;
    

    I don't know if there is anything missing in my Eclipse or not. Is there any suggestion so that I can fix it?

    "The import org.mockito cannot be resolved" just appeared on the error box.