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.

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),增城企業(yè)網(wǎng)站建設(shè),增城品牌網(wǎng)站建設(shè),網(wǎng)站定制,增城網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,增城網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。

 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://muchs.cn/article32/piojsc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站移動網(wǎng)站建設(shè)、網(wǎng)站內(nèi)鏈定制開發(fā)、域名注冊、Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)