Zend Studio 运行phpunit (原创)

Zend Studio 本身是支持phpunit 测试,而我们的需求是测试用例代码中无需直接加载

而其提供的工具无法满足此要求。最终只能通过修改Zend Studio插件的方式才能来满足要求

 

1、修改Zend Studio 插件phpunit 代码

打开文件:

D:\Program Files\Zend\Zend Studio 9.0.4\plugins

\com.zend.php.phpunit_9.0.4.201210081806\resources\ZendPHPUnit.php

 

找到

require_once 'PHPUnit/Autoload.php';

require_once'PHPUnit/Framework/Error/Notice.php';

require_once'PHPUnit/TextUI/TestRunner.php'

 

在require_once'PHPUnit/TextUI/TestRunner.php' 下加入代码

 

$_tcfile = $GLOBALS['ZendPHPUnitTests'][0];

if ($_tcfile['file']) {

 //找出项目名称,或测试类型

preg_match('/(.+)\/test\/([A-Za-z]+)\/([A-Za-z]+)\//',str_replace('\\','/',$_tcfile['file']), $_phpunittmatch);

 require_once $_phpunittmatch[1].'/test/'.$_phpunittmatch[2].'/'.$_phpunittmatch[3].'Init.php';

}

 

运行测试文件:UserServiceTest.php,把文件中下面的代码删除

require_once'PHPUnit/Autoload.php';

require_once'../ServiceInit.php';

 

UserServiceTest.php上右键->run as ->phpunittest,这时会显示phpunit 插件框,会显示红条,绿条表示测试通过与否,截图看看

 

特别说明:

在UserServiceTest.php上右键  这步必须!!!!!!!!

 

2、Zend Studio 配置外部工具执行phpunit

 

点击run->external tools->external tools Configurations, 如图

 

点击小下拉箭头取消Filter Configuration Type

 

 

双击Program 自动创建外部工具

#命令的地址

location:D:\Program Files\wamp\bin\php\php5.3.3\phpunit.bat

#执行命令的目录

working:${project_loc}

#执行命令的参数

arguments:--bootstrap=test/Web/Library/ServiceInit.php${resource_loc}

如图

 

点击Common,在dispaly in favorites menu 选择显示的菜单,打钩就行

 

 

执行外部工具

点击run->external tools->外部工具名称,前面是绿色图标的名称 点击它




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值