PHPUnit 安装和使用
来源:互联网 发布:大数据元年是哪一年 编辑:程序博客网 时间:2024/06/05 16:46
PHP环境说明:
PHP版本:5.2.6(采用Appserv2.5.9搭建)
安装目录:D:/AppServ/php5
文档根目录:D:/Appserv/www
安装
-------------------------------------------
1.双击运行 D:\AppServ\php5\go-pear.bat
CMD下会出现以下提示:全部回车即可
Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :
1-10, 'all' or Enter to continue:
Would you like to alter php.ini <C:\WINDOWS\php.ini>? [Y/n] :
Current include path : .;C:\php5\pear
Configured directory : D:\AppServ\php5\pear
Currently used php.ini (guess) : C:\WINDOWS\php.ini
Press Enter to continue:
** WARNING! Old version found at D:\AppServ\php5, please remove it or be sure to
use the new d:\appserv\php5\pear.bat command
The 'pear' command is now at your service at d:\appserv\php5\pear.bat
* WINDOWS ENVIRONMENT VARIABLES *
For convenience, a REG file is available under D:\AppServ\php5\PEAR_ENV.reg .
This file creates ENV variables for the current user.
Double-click this file to add it to the current user registry.
2.安装好之后,php5目录下有了pear.bat。运行cmd命令,D:\AppServ\php5>pear install phpunit2,将会提示
pear/PHPUnit2 can optionally use PHP extension "xdebug"
pear/PHPUnit2 requires package "pear/Benchmark"
安装xdebug
注意
1.xdebug.dll文件必须与php版本、TS相匹配,下载地址 http://xdebug.org/files/php_xdebug-2.2.3-5.2-vc9.dll
2.必须安装为zend_extension (extension=php_xdebug.dll这句不能写!)
在 C:/Windows/php.ini 文件中写入如下内容
[Xdebug]
zend_extension = "d:/AppServ/php5/ext/php_xdebug.dll"
xdebug.remote_enable = on
xdebug.trace_output_dir = "D:/AppServ/php5/tmp"
安装Benchmark:运行cmd命令
D:\AppServ\php5>pear install Benchmark
安装phpunit:运行cmd命令
D:\AppServ\php5>pear install phpunit2
测试示例
-------------------------------------------
1.项目文件:Trans.php
内容为:
<?php
class Trans{
public function func1( $a ){
return $a+2;
}
}
?>
2.PHPUnit单元测试文件:Test.php
内容为:
<?php
require_once 'PHPUnit2\Framework\TestCase.php';
require_once 'Trans.php';
class Test extends PHPUnit2_Framework_TestCase {
public $obj;
protected function setUp() {
parent::setUp ();
$this->obj = new Trans();
}
protected function tearDown() {
parent::tearDown ();
}
public function __construct() {}
public function testFunc1(){
$a = $this->obj->func1( 1 );
$b = 3;
$this->assertEquals( $b,$a );
}
}
?>
3.在cmd下运行命令:D:\AppServ\php5>phpunit Test D:/AppServ/www/Test.php
会出现以下提示
Time: 0.000232
OK (1 test)
- PHPUnit 安装和使用
- php和phpunit的安装与使用
- 使用Pear安装PHPUnit
- 【phpunit】phpunit初次安装使用简记
- PHPUnit的安装与使用
- composer安装phpunit并使用
- composer安装phpunit并使用
- 安装PHPUnit
- PHPUnit安装
- PHPUnit 安装
- phpunit安装
- PHPUnit安装
- phpunit 安装
- phpunit 安装
- phpunit安装
- PHPUnit安装
- 单元测试phpunit安装及使用实例
- WAMP下安装PEAR和PHPUnit
- Oracle Parallel Execution
- 对linux中多线程编程中pthread_join的理解
- 【博客之星】坚持,是一种信仰
- Oracle 11g Automatic Memory Management
- sencha touch 中实现一个view的刷新
- PHPUnit 安装和使用
- Java虚拟机学习 - 对象引用强度
- 【Pia开发日记】cocos2d-x CCSprite被AddChild后出现Bug,而CCLayer不会
- 深入理解linux内核v4l2框架之videobuf
- C/C++动态链接库(来源http://msdn.microsoft.com/en-us/library/vstudio/abx4dbyh.aspx)
- mono touch:Displaying Images
- 手机摄像头工作原理
- Oracle Database Cardinality Feedback
- minGW官方版与TDM版构建的差异(gcc -v)