JUnit: Hamcrest使用
来源:互联网 发布:商品上淘宝首页 编辑:程序博客网 时间:2024/05/29 17:53
转自:http://blog.csdn.net/androidbluetooth/article/details/6406208
hamcrest是一款比较不错的JUnit测试jar包,本文介绍hamcrest在Java语言的使用。如果你使用过eclipse和JUnit4的话,hamcrest的使用会让你如虎添翼。
1. 下载hamcrest
连接Google,搜索hamcrest即可。
下载列表:http://code.google.com/p/hamcrest/downloads/list
选择Full Hamcrest distribution 版本,完整版。如果是在linux下面,可以下载tgz格式的。win下面下载zip吧。其他系统的可以
根据情况下载。
2. 解压缩
tar -zxvf ×××.tgz
解压之后,将文件夹放到合适的目录下面。假设路径为/home/mark/tools/hamcrest-1.2
3. hamcrest与Eclipse
假设你已经新建一个测试项目叫TestHamcrest,并且已经导入了JUnit4这个包。如果没有的话,请参考其他关于JUnit的使用的文章。
在Eclipse中,对项目TestHamcrest右键,选择Build Path / Add External Archives。
选择/home/mark/tools/hamcrest-1.2下面的hamcrest-core-1.2.jar、hamcrest-library-1.2.jar两个jar文件。
项目中可以
- import static org.hamcrest.Matchers.*;
那么,就可以直接使用其中的方法。更多关于hamcrest的使用,请参阅文档!
4. 遇到麻烦
trouble: SecurityException异常
methond:删除JUnit包,然后在Referenced Library中再导入Junit包。
- JUnit: Hamcrest 使用
- JUnit: Hamcrest使用
- Junit hamcrest使用
- Junit中使用hamcrest
- Junit hamcrest使用
- junit搭配hamcrest使用
- junit--hamcrest
- 学习junit和hamcrest的使用
- 使用Hamcrest增强JUnit的测试能力
- 使用Junit和hamcrest包进行单元测试
- 解决“java.lang.NoSuchMethodError: org.hamcrest.core.AllOf.allOf…”问题(使用JUnit和Hamcrest)
- JUnit使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误
- junit测试hamcrest断言
- JUnit 4 with Hamcrest
- JUnit 4 with Hamcrest
- Junit hamcrest相关问题
- JUnit注解与hamcrest
- Hamcrest使用
- 杭电hdu 1564 Play a game 博弈?
- 第八周任务1方案2
- hibernate中的Annotation补充
- N种方法使用C++调用C#.NET库
- struts error和message标签学习
- JUnit: Hamcrest使用
- javascript阻止事件冒泡
- JavaScript事件编程入门案例和对对象属性的遍历
- IP地址 DWORD与字符串转换
- Logminer的使用
- SQL面试题
- packet
- spring ibatis 配置事务
- Map的简单用法入门