【Junit】JUnit-4.12使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误

  下载了最新的JUnit版本,是4.12,结果尝试使用发现老是报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing这样的错误,java

上网查了一下,通常的解决方案是,换一个低一点的版本就行了。还有人说,是缺乏hamcrest的包。去官网又看了一下,结果发现这样一段话:maven

  • 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包了,不知道做者是怎么想的。ui

 

最好的解决方法是:this

(1)换成junit-4.8.jarspa

(2)junit-4.12.jar + hamcrest-core-1.3.jarrest

下载连接:code

junit-4.12.jarget

hamcrest-core-1.3.jarit

相关文章
相关标签/搜索