Spring4.3.8使用单元测试报错

来源:互联网 发布:淘宝首页海报怎么做 编辑:程序博客网 时间:2024/05/22 05:15

1.添加junit-4.8.2.jar,测试出现问题报错java.lang.noclassdeffounderror:org/apache/commons/logging/LogFactory,查询发现是缺少支持jar,添加支持commons-logging-1.1.3.jar

2.继续报错需要junit-4.12以上

3.添加支持junit-4.12.jar

4.运行继续报错,java.lang.noclassdeffounderror:org/hamcrest/SelfDescribing

终极解决,查询发现:

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.11中没有hamcrest包了
最好的解决方法是:

使用是导入包的方案:junit.jar + hamcrest-core.jar + hamcrest-library.jar

分别下载所用jar,hamcrest-core-1.3.jar和hamcrest-library-1.3.jar

运行测试,问题解决。

原创粉丝点击