Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ZendFramework2-PHPUnit-命令行工作,NetBeans状态“;“未执行任何测试”;_Phpunit_Zend Framework2_Netbeans 7.3 - Fatal编程技术网

ZendFramework2-PHPUnit-命令行工作,NetBeans状态“;“未执行任何测试”;

ZendFramework2-PHPUnit-命令行工作,NetBeans状态“;“未执行任何测试”;,phpunit,zend-framework2,netbeans-7.3,Phpunit,Zend Framework2,Netbeans 7.3,在Zend Framework 2中为自己的模块执行PHPUnit测试时,我似乎有点问题 操作系统:Mac OS 10.8.3 Zend Framework 2.1.4 PHPUnit版本3.7.19(通过pear安装) PHP版本5.3.15(启用xdebug,版本2.1.3) 我按照Zend指南的说明创建了模块“Album”() 我不想把单元测试放在模块文件夹中,而是想把它们都放在一个集中的文件夹中。这是我的应用程序的基本结构: -配置 -数据 -模块 -公共的 -测试 --模块 ---相册

在Zend Framework 2中为自己的模块执行PHPUnit测试时,我似乎有点问题

操作系统:Mac OS 10.8.3
Zend Framework 2.1.4
PHPUnit版本3.7.19(通过pear安装)
PHP版本5.3.15(启用xdebug,版本2.1.3)

我按照Zend指南的说明创建了模块“Album”()

我不想把单元测试放在模块文件夹中,而是想把它们都放在一个集中的文件夹中。这是我的应用程序的基本结构:

-配置
-数据
-模块
-公共的
-测试
--模块
---相册
----AlbumTest.php
--Bootstrap.php
--phpunit.xml
-供应商
…(许可证、自述、编写器和init_autoloader.php)

->模块相册的测试位于“测试”中的文件夹“模块/相册”中。文件夹“tests”还包含Bootstrap.php和phpunit.xml

以下是文件的内容:

Bootstrap.php

<?php

/*
 * Set error reporting to the level to which Zend Framework code must comply.
 */
error_reporting( E_ALL | E_STRICT );

/*
 * The first run required me to fix some constants
 */
defined('TESTS_ZEND_FORM_RECAPTCHA_PUBLIC_KEY') || define('TESTS_ZEND_FORM_RECAPTCHA_PUBLIC_KEY', 'public key');
defined('TESTS_ZEND_FORM_RECAPTCHA_PRIVATE_KEY') || define('TESTS_ZEND_FORM_RECAPTCHA_PRIVATE_KEY', 'private key');
defined('TESTS_ZEND_LDAP_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', 'someUser@example.com');
defined('TESTS_ZEND_LDAP_ALT_USERNAME') || define('TESTS_ZEND_LDAP_ALT_USERNAME', 'anotherUser');

chdir(dirname(__DIR__));

/*
 * autoload the application
 */
include __DIR__ . '/../init_autoloader.php';

Zend\Mvc\Application::init(include 'config/test.config.php');
无论如何,我可以通过shell(终端)成功地做到这一点。如果我直接挂载tests目录并运行phpunit,使用phpunit二进制文件的完整路径(以确保我没有使用不同的版本),指定phpunit.xml的完整路径,等等,这并不重要。以下是一些示例:

phpunit
phpunit -c FULL_PATH/tests/phpunit.xml
/usr/local/pear/bin/phpunit -c FULL_PATH/tests/phpunit.xml
所有这些命令都给了我我所期望的:

PHPUnit 3.7.19 by Sebastian Bergmann.

Configuration read from FULL_PATH/tests/phpunit.xml

.....

Time: 0 seconds, Memory: 12.75Mb

OK (5 tests, 16 assertions)
  • 我不明白,为什么它在shell中工作,而不是通过NetBeans
  • NetBeans使用350MB,而在shell中仅使用12.75MB
  • 如果我删除了“在运行测试之前请求测试组”选项,它似乎会尝试运行所有ZendTests。不知道这是怎么可能的,从phpunit.xml应该找不到它们

感谢您的帮助,谢谢

我终于明白了,到底发生了什么。我之前使用phpunit.xml运行了ZendTests,它位于vendor/zendframework/zendframework/tests中
出于某种原因,如果选择了不同的phpunit.xml,NetBeans会保存testfile目录,它会在第一次测试运行中找到该目录,并且不会释放它们。我必须通过“右键单击项目”-“属性”-“源”-“测试文件夹”更改“新”测试目录的路径。

现在NetBeans运行测试并提供与CLI完全相同的输出

PHPUnit 3.7.19 by Sebastian Bergmann.

Configuration read from FULL_PATH/tests/phpunit.xml



Time: 9 seconds, Memory: 348.25Mb

[2KNo tests executed!
[2K
Generating code coverage report in Clover XML format ... done
phpunit
phpunit -c FULL_PATH/tests/phpunit.xml
/usr/local/pear/bin/phpunit -c FULL_PATH/tests/phpunit.xml
PHPUnit 3.7.19 by Sebastian Bergmann.

Configuration read from FULL_PATH/tests/phpunit.xml

.....

Time: 0 seconds, Memory: 12.75Mb

OK (5 tests, 16 assertions)