JUnit-4.12:java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

最近光在看别的,没咋写代码,都手生了。
写老师留的扫雷作业的测试类,在idea中直接导入了idea自带的Junit4.12包,运行测试类时报错
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
解决方法:导入idea自带的另一个包:hamcrest-core-1.3.jar
原因:
junit.jar: Includes the Hamcrest classes. The simple all-in-one solution to get started quickly.Starting with version 4.11, Hamcrest is no longer included in this jar.
junit-dep.jar: Only includes the JUnit classes but not Hamcrest. Lets you use a different Hamcrest version.


往项目中导入jar包:
File –> Project Structure –> Modules –> dependencies –> 右侧绿色加号

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章