JUnit: Hamcrest 使用
2013-09-01 12:27
363 查看
hamcrest 是一款比较不错的 JUnit 测试 jar 包,本文介绍 hamcrest 在Eclipse下的使用。
本文出自 “技术博客” 博客,请务必保留此出处http://liuxin0422.blog.51cto.com/7368853/1286557
1.下载hamcrest
直接在Google中搜索hamcrest即可。附下载地址:http://code.google.com/p/hamcrest/downloads/list选择 Full Hamcrest distribution 版本,完整版。如果是在 linux 下面,可以下载tgz格式的。根据不同的需要进行选择下载就可以。2.在Eclipse下使用hamcrest
将压缩包进行解压。假设你已经新建一个测试项目叫 TestHamcrest,并且已经导入了 JUnit4 这个包。在 Eclipse 中,对项目 TestHamcrest 右键,选择 Build Path / Add External Archive。选择刚才解压过的文件夹下面的 hamcrest-core-1.3.jar、hamcrest-library-1.3.jar 两个 jar 文件。另外,在测试的class中导入:importstatic org.hamcrest.Matchers.*;在这里就可以使用assertThat方法了。3.遇到的问题
运行时抛出SecurityException异常。解决办法:将Eclipse中默认的Junit包移除,参照上一步的方法导入新版本的JUnit即可。附:junit-4.8.2.jar包下载地址:http://download.csdn.net/detail/zht0627/3125442本文出自 “技术博客” 博客,请务必保留此出处http://liuxin0422.blog.51cto.com/7368853/1286557
相关文章推荐
- JUnit-4.11使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误 .
- JUnit: Hamcrest使用
- Junit中使用hamcrest
- 解决“java.lang.NoSuchMethodError: org.hamcrest.core.AllOf.allOf…”问题(使用JUnit和Hamcrest)
- 软件测试之实验一——如何使用JUnit,Hamcrest和Eclemma进行简单的软件测试
- junit搭配hamcrest使用
- JUnit中使用Hamcrest测试框架的assertThat断言
- 使用Ant运行JUnit测试用例时,报java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing的一种解决方案
- Junit hamcrest使用
- 软件测试(三)——Junit、Hamcrest、Eclemma的安装和使用
- 使用junit单元测试的java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing问题解决办法
- [软件测试_LAB1]安装junit和hamcrest及其使用
- 使用Hamcrest增强JUnit的测试能力
- 学习junit和hamcrest的使用
- JUnit-4.11使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误 .
- 软件测试实验——junit, hamcrest 和 eclemma的安装及使用
- 学习junit和hamcrest的使用
- junit搭配hamcrest使用
- JUnit中使用Hamcrest测试框架的assertThat断言【4.4新特性】
- 使用Junit和hamcrest包进行单元测试