下载了最新的JUnit版本,JUnit-4.12使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误
上网查了一下,一般的解决方案是,换一个低一点的版本就好了。还有人说,是缺少hamcrest的包。去官网又看了一下,结果发现这样一段话:
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.注意黑色加下划线的部分。说明4.1.2中没有hamcrest包使用请搭配: junit-4.12.jar + hamcrest-core-1.3.jar。
所以现在有两个办法解决:
1.junit版本降到4.10
2.导入hamcrest-core-1.3.jar