cakephp 單元測試斷言方法總結

來源:互聯網
上載者:User

標籤:http   io   使用   ar   資料   sp   on   html   c   

前言 cakephp 的單元測試

參考http://book.cakephp.org/2.0/en/development/testing.html

以下是CakeTestCase類的斷言,也就是cakephp 定義的斷言,實際使用中還可以使用CakeTestCase的父類 PHPUnit_Framework_TestCase裡面的斷言

1、assertEqual

是否相等,測試期望的資料和結果是否相等

2、assertNotEqual

是否不相等

3、assertPattern

是否符合正則匹配

4、assertIdentical

是否恒等(類型一樣)

5、assertNotIdentical

是否不恒等

6、assertNoPattern

是否符合正則不匹配

7、expectException

是否會遇到一個異常

8、assertReference

是否會遇到一次跳轉

9、assertIsA

是否是對象

10、assertWithinMargin

在一個範圍內波動

 

PHPUNIT的斷言在這個文檔裡面有詳細說明,還有各種格式(html,pdf,epub),https://phpunit.de/documentation.html

 

cakephp 單元測試斷言方法總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.