Netbeans-PHPUnit“未执行测试"错误 [英] Netbeans-PHPUnit "No tests executed" error
问题描述
我是任何测试的新手.我刚刚使用此安装了pear和PHPUnit. doc .我使用netbeans 7.3.1.我还安装了skeletongenerator
并运行以下命令:pear install phpunit/PHPUnit_SkeletonGenerator
.
I am newbie to any kind of testing. I just installed pear and PHPUnit using this doc. I use netbeans 7.3.1. I also installed skeletongenerator
running this command : pear install phpunit/PHPUnit_SkeletonGenerator
.
我按照此使用PHPUnit测试将PHPUnit集成到netbeans.
如该文档的Installing PHPUnit
部分所述,通过单击Netbeans->preferences->unit testing
下的search
按钮,我的netbeans可以识别PHPUnit安装.
I Followed the steps listed in this testing with PHPUnit to integrate PHPUnit to netbeans.
As described in Installing PHPUnit
section of that doc, by clicking search
button under Netbeans->preferences->unit testing
my netbeans recognizes PHPUnit installation.
我按照所有步骤添加了示例Calculator
项目并生成了测试类.我做到了但是,当我通过右键单击Calculator.php文件并选择Test
运行测试时,得到以下结果.
I followed all the steps to add sample Calculator
project and generate test class. I did that. But when I run the tests by right clicking Calculator.php file and selecting Test
I get following result.
输出"窗口显示无用:
我不知道可能是什么问题以及如何解决这个问题.
I have no idea of what can be the problem and how to solve that.
很少有可能引起上述问题的疑问:
我应该在Netbeans->preferences->general
下的Global include path
中添加什么?
我是否需要在Calculator.php文件中添加require_once
语句?
我是否只需要在某些特定文件夹下创建php项目,或者放置项目的位置无关紧要?
如何检查PHPUnit是否已正确安装并且可以正常工作?
Few doubts that may be causing the above problem :
What should I add in Global include path
under Netbeans->preferences->general
?
Do I need to add require_once
statement in Calculator.php file?
Do I need to create php projects under some particular folder only or is it immaterial where I place projects?
How do I check that PHPUnit is installed properly and is working?
我什至无法想到许多其他症状.
There can be many other symptoms that I am not even able to think of.
谢谢.
推荐答案
通过在Calculatortest.php
文件中添加以下行来解决.
Solved by adding below line to Calculatortest.php
file.
require_once dirname(__FILE__) . '/../Calculator.php';
测试类位于子目录中,因此我需要声明相对于Calculator.php的路径.
The test class is placed in a subdirectory, so I needed to declare the path relative to the Calculator.php.
此外,我不得不更改php.ini文件,以便在出现错误的情况下显示错误.
我在php.ini中设置了以下变量.
Also, I had to change php.ini file so that errors are displayed in case there are.
I set following variables in php.ini.
error_reporting = E_ALL | E_STRICT
display_errors = On
这篇关于Netbeans-PHPUnit“未执行测试"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!