The import org.junit cannot be resolved

前端 未结 13 2050
梦谈多话
梦谈多话 2020-12-04 09:49

I need to solve a java problem for an interview, and they have sent me the test class. It starts with

import org.junit.Before;

and also ha

相关标签:
13条回答
  • 2020-12-04 10:40

    In starting code line copy past 'Junit' or 'TestNG' elements will show with Error till you import library with the Project File.

    To import Libraries in to project:

    Right Click on the Project --> Properties --> Java Build Path --> Libraries -> Add Library -> 'Junit' or 'TestNG'

    Add Junit Libraries

    0 讨论(0)
  • 2020-12-04 10:44

    If you use maven and this piece of code is located in the main folder, try relocating it to the test folder.

    0 讨论(0)
  • 2020-12-04 10:45

    When you add TestNG to your Maven dependencies , Change scope from test to compile.Hope this would solve your issue..

    0 讨论(0)
  • 2020-12-04 10:46

    Seem to Junit jar file is not in path also make sure you are using jdk1.5 or above.

    0 讨论(0)
  • you need to add Junit dependency in pom.xml file, it means you need to update with latest version.

    <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency> 
    
    0 讨论(0)
  • 2020-12-04 10:48

    If using Maven you can context click and run 'Maven/Update Project...'

    0 讨论(0)
提交回复
热议问题