method initializationerror not found:JUnit4单元测试报错问题
来源:互联网 发布:淘宝频道退货 编辑:程序博客网 时间:2024/04/29 15:05
今天使用JUnit 4进行单元测试时,测试程序一直运行不起来,报method initializationerror not found错误,如下:
网上说版本不对,我试了试,还是有这个问题,后来才知道,缺少了jar包,除了引入junit-4.12.jar之外,还要引入2个依赖jar包:hamcrest-core-1.3.rc2.jar,hamcrest-library-1.3.rc2.jar,提供大家免费的下载链接:
junit-4.12.jar下载
hamcrest-library-1.3.rc2.jar下载
hamcrest-core-1.3.rc2.jar下载
导入这些jar包之后,问题游刃而解,是的,我承认自己也是JUnit新手。
至于JUnit的jar包和hamcrest的jar包关系,下边我引用一位网友的几段话来解释解释:
junit和hamcrest是两个不同的框架,不同的东西。只不过是junit使用了hamcrest框架而已。
在junit上下载的junit的包解压开见下图:
刚下载的JUnit的jar包解压开的文件。
junit-4.10.jar :包含junit-dep-4.10.jar全部内容和必要的harmcres的包,
junit-4.10-src:是源代码,但不包含org.harmcres.*相关的源代码(在图中temp.hamcrest.source中)。
junit-dep-4.10.jar :是junit的包,不含harmcres的相关的类,import此包还需引入harmcres相关的包。
下载到关于hamcrest的相关的一系列的包(如果是java就下载jar的包)
hamcrest-all-1.3.ORC2.ajr:几乎包含所有的hamctest的类(没有验证过)。
hamcrest-core-1.3.ORC2.jar:hamcrest的核心包,使用hamcrest框架必须引入的包。(junit官方给的包就包含了该包)
hamcrest-library-1.3.ORC2.jar:包含各种断言,补充hamcrest core包中的断言。
使用是导入包的方案:junit.jar + hamcrest-core.jar + hamcrest-library.jar
或者是:junit-dep.ajr+hancrest-all.jar
这两种导入方法虽然尽量避免了导入重复的包,但使用时还是遇到了冲突。查看包中各类和文档后发现有些类(例如:断言is())同时出现在了org.hamcrest.Mathchers和org.hamcrest.core中,则在用到时候引入的时候需要注意。
- method initializationerror not found:JUnit4单元测试报错问题
- method initializationerror not found:JUnit4单元测试报错问题
- method initializationerror not found:JUnit4单元测试报错问题
- JUnit4单元测试报错问题 :method initializationerror not found
- JUnit4单元测试报错问题:method initializationerror not found
- method initializationerror not found:JUnit4单元测试报错问题
- SpringBoot单元测试报错问题method initializationerror not found:JUnit4
- method initializationerror not found:JUnit4单元测试报错问题
- 【JUnit 报错】 method initializationerror not found:JUnit4单元测试报错问题
- 【JUnit 报错】 method initializationerror not found:JUnit4单元测试报错问题
- 【JUnit 报错】 method initializationerror not found:JUnit4单元测试报错问题
- Myeclipse解决method initializationerror not found:JUnit4单元测试报错问题
- method initializationerror not found单元测试
- JUnit报错method initializationerror not found的相关问题
- Junit单元测试遇到的initializationerror:method initializationerror not found
- eclipse junit 问题:"method initializationerror not found"
- JUnit4 测试 Parameterized 报错Unrooted Tests : No tests found matching Method initializationError解决方法
- JUnit4 initializationError[Runner:JUnit4](0.001s)junit4报错
- OJ 15之简单A+B
- Objective-C基础——block
- c# 委托类传值简单实例
- 【Java集合源码剖析】Hashtable源码剖析
- 2015年大一下第1周项目1-阅读程序(2)
- method initializationerror not found:JUnit4单元测试报错问题
- iOS的重用机制
- actor中!(tell)与forward的区别
- 你刚在淘宝上买了一件衣服---详细解析技术流程(淘宝首页显示一个页面的过程)
- 三层登陆问题——未处理AccessViolationException,试图读取或写入受保护的内存。这是通常指示其他内存已损坏。
- UVA 1364 - Knights of the Round Table (找双连通分量 + 二分图染色法判断)
- OJ 21之Mincost(
- 十、oc中@property参数的学习
- Linux的文件权限