现在已经2天了,我一直试图让phpunit在我的OSX上工作.我正在从MAMP安装运行php.
我已经通过PEAR安装了所有依赖项.phpunit --version命令正在运行并显示:
$ phpunit --version
PHPUnit 3.6.10 by Sebastian Bergmann.
Run Code Online (Sandbox Code Playgroud)
但是,当我从命令行运行测试时,它显示:
Warning: require_once(/Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Framework): failed to open stream: No such file or directory in /Users/magalie/Sites/HelloWorld/HelloWorldTest.php on line 3
Call Stack:
0.0028 632128 1. {main}() /Applications/MAMP/bin/php/php5.3.6/bin/phpunit:0
0.0078 1161288 2. PHPUnit_TextUI_Command::main() /Applications/MAMP/bin/php/php5.3.6/bin/phpunit:46
0.0078 1162016 3. PHPUnit_TextUI_Command->run() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/TextUI/Command.php:130
0.1109 1793352 4. PHPUnit_Runner_BaseTestRunner->getTest() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/TextUI/Command.php:150
0.1109 1793352 5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Runner/BaseTestRunner.php:104
0.1115 1837832 6. PHPUnit_Runner_StandardTestSuiteLoader->load() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Runner/BaseTestRunner.php:168
0.1126 1983864 7. PHPUnit_Util_Fileloader::checkAndLoad() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Runner/StandardTestSuiteLoader.php:78
0.1127 1983984 8. PHPUnit_Util_Fileloader::load() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Util/Fileloader.php:79
0.1128 1994704 9. include_once('/Users/magalie/Sites/HelloWorld/HelloWorldTest.php') /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Util/Fileloader.php:95
Fatal error: require_once(): Failed opening required 'PHPUnit/Framework' (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php:/Applications/MAMP/bin/php5.3/lib/php/PEAR:/usr/lib/php') in /Users/magalie/Sites/HelloWorld/HelloWorldTest.php on line 3
Call Stack:
0.0028 632128 1. {main}() /Applications/MAMP/bin/php/php5.3.6/bin/phpunit:0
0.0078 1161288 2. PHPUnit_TextUI_Command::main() /Applications/MAMP/bin/php/php5.3.6/bin/phpunit:46
0.0078 1162016 3. PHPUnit_TextUI_Command->run() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/TextUI/Command.php:130
0.1109 1793352 4. PHPUnit_Runner_BaseTestRunner->getTest() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/TextUI/Command.php:150
0.1109 1793352 5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Runner/BaseTestRunner.php:104
0.1115 1837832 6. PHPUnit_Runner_StandardTestSuiteLoader->load() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Runner/BaseTestRunner.php:168
0.1126 1983864 7. PHPUnit_Util_Fileloader::checkAndLoad() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Runner/StandardTestSuiteLoader.php:78
0.1127 1983984 8. PHPUnit_Util_Fileloader::load() /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Util/Fileloader.php:79
0.1128 1994704 9. include_once('/Users/magalie/Sites/HelloWorld/HelloWorldTest.php') /Applications/MAMP/bin/php/php5.3.6/lib/php/PHPUnit/Util/Fileloader.php:95
Run Code Online (Sandbox Code Playgroud)
这是梨的配置
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels auto_discover 1
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy <not set>
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config <not set>
PEAR executables directory bin_dir /Applications/MAMP/bin/php/php5.3.6/bin
PEAR documentation directory doc_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/doc
PHP extension directory ext_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions
PEAR directory php_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/
PEAR Installer cache directory cache_dir /var/folders/qH/qHdMKNY5GsywPNMBPX-T7U+++TI/-Tmp-//pear/cache
PEAR configuration file cfg_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/cfg
directory
PEAR data directory data_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/data
PEAR Installer download download_dir /var/folders/qH/qHdMKNY5GsywPNMBPX-T7U+++TI/-Tmp-//pear/download
directory
PHP CLI/CGI binary php_bin /Applications/MAMP/bin/php/php5.3.6/bin/php
php.ini location php_ini /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
--program-prefix passed to php_prefix <not set>
PHP's ./configure
--program-suffix passed to php_suffix <not set>
PHP's ./configure
PEAR Installer temp directory temp_dir /var/folders/qH/qHdMKNY5GsywPNMBPX-T7U+++TI/-Tmp-//pear/temp
PEAR test directory test_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/tests
PEAR www files directory www_dir /Applications/MAMP/bin/php/php5.3.6/lib/php/www
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state stable
Unix file mask umask 22
Debug Log Level verbose 1
PEAR password (for password <not set>
maintainers)
Signature Handling Program sig_bin /usr/local/bin/gpg
Signature Key Directory sig_keydir /Applications/MAMP/bin/php/php5.3.6/pearkeys
Signature Key Id sig_keyid <not set>
Package Signature Type sig_type gpg
PEAR username (for username <not set>
maintainers)
User Configuration File Filename /Users/magalie/.pearrc
System Configuration File Filename /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
Run Code Online (Sandbox Code Playgroud)
和phpunit是从/ usr/lib/php运行的,这是$ PATH的一部分
这是我的HElloWorldTest.php文件的内容,我已经尝试过使用或不使用Framework文件的php扩展但没有成功.
<?php
require_once 'HelloWorld.php';
require_once 'PHPUnit/Framework';
///Applications/MAMP/bin/php/php5.3.6/lib/php/
class HelloWorldTest extends PHPUnit_Framework_TestCase
{
public function test__construct()
{
$hw = new HelloWorld();
$this->assertType('HelloWorld, $hw');
}
public function testSayHello()
{
$hw = new HelloWorld();
$string = $hw->sayHello();
$this->asserEquals('Hello World!', $string);
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试卸载并重新安装phpunit,没有运气.在PHPUnit目录中查找,没有Framework.php文件.
那我做错了什么?有没有人有同样的问题?你是怎么解决的?这让我发疯,我的印象就是围成一圈......
谢谢你的帮助.
您不需要在测试中加载PHPUnit.该phpunit可执行文件需要搭建自己的自动加载的照顾.删除此行:
require_once 'PHPUnit/Framework';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2867 次 |
| 最近记录: |