今天測試的是將老的lib中的junit包更換爲了新的4.12版本,運行測試的時候,發現本應該正常通過的測試居然failed了。
查看report裏面的詳細信息:
這裏面是initializationError,網上查了下,遇到這總問題的還不少,都是更換了新的junit包導致的,但是現象貌似各有不同。
還有人說,是缺少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包了
最好的解決方法是:
(1)換成junit-4.8.jar
(2)junit-4.12.jar + hamcrest-core-1.3.jar
下載鏈接:
兩種方法都進行了測試,均能成功解決問題。