利用 zend studio 9 run as phpunit test 总结
ps:原创文章,如需转载,请注明出处,谢谢!
本文地址:http://flyer0126.iteye.com/blog/1441889
?
? 利用本地php环境中的phpunit.bat测试同一单元测试用例,发现没有任何错误,如下图:
而利用 zend studio 9 创建phpunit单元测试用例,run as phpunit test 时发现,总是弹出一个错误框,提示如下信息:
? “no test executed, either a fatal error occurred, the launch was stopped manually or the script execution was halted with a ‘die’/'exit’ statement.”
? 只是这样一条提示,是解决不了什么问题的。这时,一般console会有相关错误信息,可以对应逐步解决。
? 后来仔细研究发现zend studio是使用自带的php程序来执行调试功能,明白这一点之后,在首选项preferences的php>php executables里,可以选择加入对应版本的php可执行程序。这样就避免出现调试同一文件时,情况不一致的问题了。
?
解决方法总结如下:
1. 项目配置:点击项目名右击:include_path->configure include path...? 添加phpunit 3.x library;
2. 环境配置:window->perferences,在php的executables中选择对应的php版本及运行环境;
3. run as phpunit test 时,选择run configurations 中在php script 标签下选择对应的php版本的运行环境方式。
?
以上项目配置完成后,可以进行phpunit的单元测试了,但是如果某次出错之后,会在运行时不运行测试程式,直接报错:
? “no test executed, either a fatal error occurred, the launch was stopped manually or the script execution was halted with a ‘die’/'exit’ statement.”
? 对于这个问题,本人也是困扰了好久,起初是通过重启zend来解决的,后来发现是由于测试出错后,在任务管理器中就多存在 php-cgi.exe 的进程,重新执行测试文件时,如果进程中存在相同的错误进程,会对测试造成影响,可以将此类同名进程终止掉之后,再进行单元测试,以上问题就解决了,ok,暂时就这么多...
?