IntroductiononUsingHamcrestUnitTestFramework

 Hamcrest is a unit test framework, the assert function assertThat of hamcrest is more human readable comparing to the assert function of Junit, therefore, Junit4 has already adopted and integrated the hamcrest framework from version 4.4 on. Please check following screenshot.

创新互联是一家集网站建设,增城企业网站建设,增城品牌网站建设,网站定制,增城网站建设报价,网络营销,网络优化,增城网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

 Introduction on Using Hamcrest Unit Test Framework

 But Junit4 integrates only the core features of hamcrest, in order to facilitate our test automation work, we should add the hamcrest JAR library with all features into our test project.

-         Hamcrest-all-xx.jar          : Contains all feature of hamcrest

-         Hamcreset-core-xx.jar : Contains core feature of hamcrest

We could download hamcrest by following this link:

http://search.maven.org/#search|ga|1|g%3Aorg.hamcrest

Following description would illustrate how to use hamcrest-all in our test project.

Step 1:Drag&drop the hamcrest-all jar package to the libs(Create one if not exist)folder of the project

Introduction on Using Hamcrest Unit Test Framework

Step 2: Import hamcrest modules into test script

Introduction on Using Hamcrest Unit Test Framework

“importstatic org.hamcrest.MatcherAssert.assertThat”:in order to use the function“assertThat”

-  “import static org.hamcrest.Matchers.*”:in order to use the matcher of“is”,”notNullValue”,”equalTo” and so on.

Step 3:Use hamcrest feature in our test script

 Introduction on Using Hamcrest Unit Test Framework

Following are the link on the syntax of asserThat function of hamcrest.

http://langgufu.iteye.com/blog/1893927

-----------------------------------------TheEnd--------------------------------------


网页题目:IntroductiononUsingHamcrestUnitTestFramework
分享网址:http://csruizhi.cn/article/piojsc.html

其他资讯

Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号
友情链接: 企业网站建设 网站建设开发 网站建设公司 成都网站设计 成都网站建设 成都网站设计 成都商城网站制作 重庆网站设计 成都网站制作 品牌网站建设 成都网站建设 做网站设计 成都定制网站建设 成都响应式网站建设 高端网站建设 四川成都网站设计 网站制作 成都网站建设 成都响应式网站建设公司 盐亭网站设计 外贸网站建设 成都网站设计制作公司