windows下安装phpunit进行单元测试
来源:互联网 发布:淘宝直通车推广要求 编辑:程序博客网 时间:2024/05/21 19:19
下载地址:http://phpunit.de/#download
配置方式:
1》命令行进入xampp的php目录 cd \xampp\php
2》添加与phpunit相关的channel
pear channel-discover pear.phpunit.de
return CMap::mergeArray(
require(dirname(__FILE__).'/main.php'),
array(
'components'=>array(
'fixture'=>array(
'class'=>'system.test.CDbFixtureManager',
),
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=imp_test',
'emulatePrepare' => true,
'username' => 'imp',
'password' => 'imp89732',
'charset' => 'utf8',
),
),
)
);
配置方式:
1》命令行进入xampp的php目录 cd \xampp\php
2》添加与phpunit相关的channel
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear channel-discover pear.symfony.com
pear install pear.symfony.com/Yaml
pear install phpunit/PHPUnit_Story
3》安装phpUnit > pear install –alldeps phpunit/PHPUnit
运行单元测试
单元测试文件放置于protected\tests\unit目录
创建测试数据 protected\tests\fixtures
使用测试数据
public $fixtures=array('数据名比如datas'=>'对应model类名',);
测试方法中使用数据集中的一条数据 $data=$this->datas('data1'); 'data1'为fixtures返回数组的关键字
运行
转到tests目录 cd xampp\htdocs\imp\protected\tests
phpunit --coverage-html ./report unit\**Test.php
建议
进行单元测试会将数据库清空,建议新建一数据库
修改 protected\config\test.php如下
return CMap::mergeArray(
require(dirname(__FILE__).'/main.php'),
array(
'components'=>array(
'fixture'=>array(
'class'=>'system.test.CDbFixtureManager',
),
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=imp_test',
'emulatePrepare' => true,
'username' => 'imp',
'password' => 'imp89732',
'charset' => 'utf8',
),
),
)
);
0 0
- windows下安装phpunit进行单元测试
- Windows下PHPUnit安装
- Windows下PHPUnit安装
- windows下phpunit安装
- windows下phpunit安装
- windows下安装PHPunit
- PHP单元测试工具phpunit安装(windows版)
- 在windows下安装phpunit
- windows xampp下安装phpunit
- 单元测试 PHPUnit 安装
- symfony2 用phpunit进行单元测试
- Windows下安装PEAR, PHPUnit成功 (
- PHPUnit 在windows下的安装教程
- windows下phpunit安装及测试
- 在windows安装PHPUnit
- phpunit windows 安装 配置
- windows安装phpunit
- phpstorm配置phpunit,进行php单元测试
- NYOJ 767 因子和
- Asp.Net Web API 2第十三课——ASP.NET Web API中的JSON和XML序列化
- byte char 区别
- 二分图最少点覆盖
- 2014年4月操作系统份额:Windows XP仍然在26%以上 Linux微涨
- windows下安装phpunit进行单元测试
- 统计字符串中汉字的个数
- Nginx担当WebSockets代理
- java.lang.OutOfMemoryError: PermGen space解决办法
- OJ-练习-复数运算符重载
- C# Dictionary 的几种遍历方法
- 管理人员的组织和资源的使用
- trsjhnfgs
- Sql Server profiler 分析器