PHPunit

回覆文章
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

PHPunit

文章 yehlu »

官方網站
https://github.com/sebastianbergmann/phpunit/

網站製作學習誌
http://www.jaceju.net/blog/archives/1062/
http://www.jaceju.net/blog/archives/1152/

壞蛋的部落格
http://www.pigo.idv.tw/archives/617

石頭閒語
http://blog.roodo.com/rocksaying/archives/2599757.html
http://blog.roodo.com/rocksaying/archives/2653972.html

教學投影片
http://www.slideshare.net/jameslabs

使用 PHPUnit 進行單元與功能測試
https://github.com/kiang/symblog-docs-t ... hpunit.rst

安裝

代碼: 選擇全部

pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony.com
pear install --alldeps pear.phpunit.de/PHPUnit
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

測試先行

文章 yehlu »

test-driven 的程式則是
先假設功能已經完成了 (有 function/method)
然後直接去呼叫, 看會傳回什麼

簡單說 你就把要寫的東西 假裝已經外包出去
你跟外包的人已經定好銜接的介面
然後你要測試他的程式有沒有問題
把測試程式都寫好
再反過來寫真正的程式

http://blog.lupopi.com/2012/05/phpunit- ... ework.html
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

phpunit.xml

文章 yehlu »

sample

代碼: 選擇全部

<!-- colors為true可以讓測試結果加上顏色方塊,bootstrap可以自行定義init程式(例如define一些變數) -->
<phpunit colors="true" bootstrap="init.php">
    <testsuite name="TestSuite">
        <directory>./tests</directory>
    </testsuite>
</phpunit>
run

代碼: 選擇全部

phpunit -c phpunit.xml
sublime Ctrl-B 設定
/home/user/.config/sublime-text-2/Packages/User/PHPUnit.sublime-build

代碼: 選擇全部

{
        "cmd": [
     "/usr/bin/phpunit",
     "-c",
     "phpunit.xml"],
     "working_dir" : "${folder}"
}

yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: PHPunit setUp tearDown

文章 yehlu »

http://blog.johnsonlu.org/phpphpunit/

setUp和tearDown是執行PHPUnit時預設執行的函式,
主要是用來初始化設定及結束設定用的,
執行順序為:setUp、test*、tearDown
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

IDE 整合

文章 yehlu »

回覆文章

回到「PHP」