在新搭建的環境上測試時,一個模塊發現錯誤:
java.lang.NoClassDefFoundError:org/hamcrest/SelfDescribing
一看就是缺少Class。多方查找,發現是少了hamcrest包。將hamcrest-core.jar加入到Build Path就可以了。
下載地址:http://www.java2s.com/Code/Jar/h/hamcrest.htm
junit與hamcrest關系參考http://blog.csdn.net/hanpompy/article/details/7622251
另:http://blog.csdn.net/hanpompy/article/details/7622251中的說法不確定是否完全正確。我使用的是junit-4.11.jar與hamcrest-core-1.3.jar,並沒有用到hamcrest-library.jar,依然可以正常測試。