从错误提示可以看出没有hamcrest包中的类
网上提供的方案
导入包的方案:junit.jar+ hamcrest-core.jar + hamcrest-library.jar
自己解决成功方案:在有junit-4.12.jar的情况下,导入hamcrest-core-1.3.jar便可以成功运行了。
maven项目可以:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- junit包 -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
附上jar包下载链接:https://download.youkuaiyun.com/download/imaniy/10688368
事后分析一下原理
发现:junit使用了hamcrest框架。junit-4.12.jar没有这个框架hamcrest,需要自己导入。