我在OSX 10.11中工作
我正在尝试使用Eclipse设置PHPUnit,MAKEGood和Xdebug。
XDebug已完成。 我可以从控制台运行PHPUnit测试。
但现在配置MakeGood比我预期的要困难得多。
我的PHP可执行文件
我是否必须在Eclipse->Preferences->PHP->Libraries
添加梨?我不确定,因为我使用Brew安装了PHPUnit。
brew install homebrew/php/phpunit
但我又试图加入PEAR。
我将路径设为usr/local/bin
,因为当我在终端中尝试which pear
时,它将输出为
/usr/local/bin/pear
在PHP->下的项目属性中包含路径我添加了上面的PEAR库。
仍然来自Makegood,错误来自
PHPUnit_Framework_TestCase class is not available. Fix..
我尝试了很多东西,例如: -
reinstalling pear
rm .metadata/.plugins/org.eclipse.dltk.core.index.sql.h2/*
restart Eclipse
Restart Computer
change pear library path
其实我不确定我做错了什么。即使我不确定我需要梨库。
感谢任何帮助。提前谢谢。
答案 0 :(得分:3)
MakeGood和Composer需要一些摆弄才能让他们上班
你可能想要
可以选择使用composer完成更新的PHPUnit版本。
首先安装作曲家:
curl -sS https://getcomposer.org/installer | php
请参阅https://phpunit.de/manual/current/en/installation.html
然后安装phpunit
php composer.phar require "phpunit/phpunit=4.8.*"
现在从命令行进行测试
vendor/phpunit/phpunit/phpunit.php test/MakeGoodTest.php
使用下面的MakeGoodTest.php文件。 结果应该是:
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Warning: Deprecated configuration setting "strict" used
.
Time: 86 ms, Memory: 4.50Mb
OK (1 test, 5 assertions)
最近的MakeGood版本支持安装了phpunit的作曲家用户。
在Eclipse项目中创建一个包含你的项目“makegood” composer安装,test / MakeGoodTest.php,MakeGoodPreload.php和phpunit.xml。
右键单击项目的属性,然后转到“MakeGood”选项卡。 在PHPUnit选项卡中添加phpunit.xml,并在General选项卡中将Preload Script设置为MakeGoodPreload.php。
现在您应该可以在编辑器中打开MakeGoodTest.php并右键单击 得到“在课堂上运行测试......”。
运行它应该给你:
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Warning: Deprecated configuration setting "strict" used
.
MakeGood
[x] [32mPush and pop[39m
Time: 192 ms, Memory: 8.75Mb
OK (1 test, 5 assertions)
<强> phpunit.xml 强>
<phpunit backupGlobals="true"
backupStaticAttributes="false"
cacheTokens="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
strict="false"
verbose="false">
</phpunit>
<强> MakeGoodPreload.php 强>
<?php
// This is a preload script to be used with
// the Eclipse makegood continuous integration plugin
// see https://github.com/piece/makegood/releases
error_reporting(E_ALL);
$loader = require 'vendor/autoload.php';
<强>测试/ MakeGoodTest.php 强>
<?php
class MakeGoodTest extends PHPUnit_Framework_TestCase
{
public function testPushAndPop()
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
}
?>