Netbeans“未执行测试" [英] Netbeans "no tests executed"
问题描述
我有一个包含单元测试的php项目.我使用Netbeans进行开发,并希望在我的IDE中集成phpunit.如果我从命令行运行phpunit,它正在工作. 如果我按Alt + F6键在Netbeans中运行测试,则不会运行任何测试,我会收到消息:
I have a php project with unit tests included. I use Netbeans for development and would like to have phpunit intergration in my IDE. If I run phpunit from the commandline, it is working. If I press Alt+F6 to run tests in Netbeans no tests run, I get the message:
未执行测试(可能发生了错误,请在输出"窗口中进行验证.)
No tests executed (Perhaps an error occurred, verify in Output window.)
结构(它是Zend Framework 2模块):
The structure (it is a Zend Framework 2 module):
Foo/
src/
Foo/
Bar.php
Baz.php
tests/
Foo/
BarTest.php
bootstrap.php
phpunit.xml
Module.php
autoload_register.php
BarTest.php的内容
Contents of BarTest.php
namespace Foo;
use PHPUnit_Framework_TestCase as TestCase;
class BarTest extends TestCase
{
public function testIsWorking ()
{
$this->assertTrue(true);
}
}
我的phpunit.xml:
My phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="bootstrap.php">
<testsuite name="Foo">
<directory>./</directory>
</testsuite>
</phpunit>
我的bootstrap.php:
My bootstrap.php:
// Set error reporting pretty high
error_reporting(E_ALL | E_STRICT);
// Get base, application and tests path
define('BASE_PATH', dirname(__DIR__));
// Load autoloader
require_once BASE_PATH . '/autoload_register.php';
在Netbeans项目属性中,我尝试过:
In the Netbeans project properties I tried:
- 要将测试目录设置为
Foo/tests
(我认为这是必需的) - 要专门设置引导文件(我认为不是必需的)
- 要专门设置XML配置文件(我认为不是必需的)
- 要专门设置为运行所有* Test文件(我认为不是必需的)
- To set the tests directory to
Foo/tests
(this is required I think) - To set specifically the bootstrap file (not required I think)
- To set specifically the XML configuration file (not required I think)
- To set specifically to run all *Test files (not required I think)
如何确保Netbeans可以执行我的phpunit测试?
推荐答案
尽管我将error_reporting设置为较高级别,但PHP CLI并未打开display_errors.就是这样,所以现在我回来了报告...
Though I had set error_reporting to a high level, the PHP CLI did not have display_errors turned on. This was it, so now I got my reporting back...
这篇关于Netbeans“未执行测试"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!