yii是基于測試驅動的,而zend studio是一個好用的ide。集成就是必須的。
本文適合喜歡使用ide的開發者,vim用戶或者文本編輯器使用者請忽略。
本文使用的是最新的zend studio (版本 10.0.0)官網下載
yii本身沒啥可說的,主要還是phpunit相關的內容。
創建完項目,寫一個簡單的testcase。
[php]
require_once 'test\CTestCase.php';
/**
* Task test case.
*/
class TaskTest extends CTestCase {
public function testNewArrayIsEmpty()
{
$fixture = array();
$this->assertEquals(0, sizeof($fixture));
}
}
[/php]
在 tests 目錄上直接 run as phpunit test
可以運行,報錯:No test executed, Either a fatal error occurred, the launch was stopped manually or the script execution was halted with a ‘die’/'exit’ statement.
查看輸出:require_once(): Failed opening required 'PHPUnit/Extensions/SeleniumTestCase.php' (include_path='.;C:\Program Files (x86)\Zend\Zend Studio 10.0.0\plugins\com.zend.php.phpunit_10.0.0.201210220951\resources\library\3.6.10\;...........
原因:phpunit默認并沒有Selenium的擴展
解決辦法:
使用自己的pear安裝的phpunit
下載一個Selenium的擴展,即可.(下載地址)解壓到phpunit目錄(就是上面輸出里面的地址)的Extensions
再次運行,正常
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。