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 –> 右側綠色加號

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