phpUnit 安装,实例和简单部署
生活随笔
收集整理的這篇文章主要介紹了
phpUnit 安装,实例和简单部署
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
背景:一個小腳本,保證穩定為主;所以試用了下phpunit,快捷方便
phpunit 的安裝
phpunit是一個輕量級的php單元測試框架,通過pear安裝
安裝過程
成功之后顯示如下:
cuihuan:~ cuixiaohuan$ phpunit --version PHPUnit 4.8.6 by Sebastian Bergmann and contributors.簡單試用
測試類集成框架
class PsCaseTest extends PHPUnit_Framework_TestCase{}
其中phpunit
默認首先執行 setup
默認最后執行 teardown
舉個栗子:
<?php /***************************************************************************** $Id: PsCaseTest,v 1.0 PsCaseTest cuihuan Exp$***************************************************************************//*** @file PsCaseTest.php* @author cuihuan* @date 2015/09/11 10:09:31* @version $Revision:1.0$* @brief pscase接口單元測試***/require_once dirname(__FILE__) . ('/PsCase.php');class PsCaseTest extends PHPUnit_Framework_TestCase {/*** @var object pscase類*/protected $pscase;/*** @brief setup: Sets up the fixture, for example, opens a network connection.** This method is called before a test is executed. */public function setup(){$this->pscase = new PsCase();}/*** @brief teardown: Tears down the fixture, for example, closes a network connection.* * This method is called after a test is executed.*/public function teardown(){}/*** @brief : 測試config文件的獲取**/public function testGetConfig(){$this->assertEquals(true,$this->pscase->debugText("11"));} }運行
運行方式:phpunit —bootstrap [源文件] 測試文件
具體如下:
部署
部署就不不贅述了,寫個shell腳本,crontab天極運行,加個報警郵件,簡單的單元測試ok,從此再也不用擔心錯誤和回歸測試了。
個人小站原文鏈接
總結
以上是生活随笔為你收集整理的phpUnit 安装,实例和简单部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MATLAB卷积动画演示
- 下一篇: mysql语法学习(一)__Instan