opensuse13.1 下phpunit+selenium


正在學習yii框架,在編寫php代碼的時候,要用到單元測試。以前只據說單元測試,沒怎麼了解過,此次要用到了。在yii框架中使用phpUnit進行單元測試真的很方便。從Yii1.1版本起,Yii已經緊密結合phpUnit和selenium remote control測試框架。 php

這是yiic webapp 自動生成的 /protected/tests/目錄,,咱們將測試文件主要放到這個目錄:fixtures , functional,unit。 html

一. 安裝PHPUnit java

(1)在命令行: web


$>sudo pear channel-discover pear.phpunit.de


$>sudo pear install phpunit/PHPUnit



這是在opensuse13.1終端上所獲得實驗步驟,可能您的配置略有不一樣。詳細安裝過程請參考http://phpunit.de/manual/3.7/en/installation.html

(2)opensuse13.1 Yast2 shell

打開yast2 出入phpunit勾選相應的選項。而後也能夠成功安裝。 app


二. 安裝selenium 框架

除了phpunit,selem remote control server 爲是了運行測試功能所須要的,安裝selenium很是簡單。 yii

[1] . 從http://code.google.com/p/selenium/downloads/list    下載 Selenium RC 的zip文件 curl

[2] .解壓下載的zip文件到你的系統中。 webapp

運行這個服務時也很簡單:

在shell下:

$>java -jar  selenium-server-standalone-2.37.0.jar


至此phpUnit安裝已經搞定,用上面的方法開啓 Selenium 服務

可是當我在 /protected/tests/> phpunit functional/SiteTest.php 時產生了錯誤。

Warning: include(): Failed opening ‘PHPUnit_Extensions_SeleniumTestCase_Driver.php 

查找資料之後在shell下面輸入:

pear upgrade -f phpunit/phpunit_selenium

php須要開啓 curl

而後重新測試看到了以下的結果

相關文章
相關標籤/搜索