沃梦达 / 编程问答 / php问题 / 正文

Netbeans-PHPUnit “未执行测试"错误

Netbeans-PHPUnit quot;No tests executedquot; error(Netbeans-PHPUnit “未执行测试错误)

本文介绍了Netbeans-PHPUnit “未执行测试"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是任何测试的新手.我刚刚使用这个 安装了 pear 和 PHPUnit文档.我使用 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.

输出窗口没有显示任何有用的信息:

Output window shows nothing useful :

我不知道可能是什么问题以及如何解决.

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 “未执行测试"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Netbeans-PHPUnit “未执行测试"错误

基础教程推荐