开始学习JUnit,按官网的操作:https://github.com/junit-team/junit4/wiki/Download-and-Install

在Eclipse里配置了Maven:

<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

右键项目,选择Maven-Update project更新项目后,按官网Demo:https://github.com/junit-team/junit4/wiki/Assertions

增加类AssertTests

 

问题:

保存AssertTests后提示:

The import org.hamcrest cannot be resolved

The import org.junit cannot be   resolved

检查BuildPath,Junit和hamcrest都已经在Maven下了:

Eclipse+Maven+JUnit时The import org.junit cannot be resolved

解决办法:

在BuildPath中Add Library,选择Junit,版本选择JUnit4,Apply后问题解决

相关文章:

  • 2021-08-09
  • 2021-11-14
  • 2022-12-23
  • 2021-10-28
  • 2021-08-08
  • 2021-05-06
  • 2021-12-16
猜你喜欢
  • 2021-04-07
  • 2022-01-21
  • 2021-12-17
  • 2021-05-23
  • 2022-12-23
  • 2021-08-27
  • 2021-11-24
相关资源
相似解决方案