Eclipse PDT 和 PHPUnit?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/966673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse PDT & PHPUnit?
提问by cirpo
Is there any integration of PHPUnit with Eclipse PDT?
是否有 PHPUnit 与 Eclipse PDT 的集成?
If not, are there any plans to do so?
如果没有,是否有这样做的计划?
采纳答案by VonC
Sebastian Bergmann did approach pdt back in 2006... but with no obvious result.
And his latest entries on his blog only mention PHPEdit 2.12 and Zend Studio.
Sebastian Bergmann确实在 2006 年就接触过 pdt......但没有明显的结果。
他在博客上的最新条目只提到 PHPEdit 2.12 和 Zend Studio。
The only testing framework officially documented on the PDT side is the "PDT Testing Framework", and it does not seem actively maintained...
在 PDT 方面官方记录的唯一测试框架是“PDT 测试框架”,它似乎没有积极维护......
So, no. There does not seem to be any plan to actively integrate PHPUnit in PDT anytime soon.
所以不行。似乎没有任何计划在短期内将 PHPUnit 积极地集成到 PDT 中。
回答by cirpo
See Eclipse Plugin PHP Tool Integration (PTI)which provides integration of following features for Eclipse:
请参阅Eclipse 插件 PHP 工具集成 (PTI),它为 Eclipse 提供了以下功能的集成:
- PHP_CodeSniffer
- PHPUnit
- PHP Depend
- PHP Copy/Paste Detector
- PHP_CodeSniffer
- PHP单元
- PHP 依赖
- PHP 复制/粘贴检测器
Update sites (Help - Install Software - Add ...):
更新站点(帮助 - 安装软件 - 添加...):
Latest stable release: http://www.phpsrc.org/eclipse/pti/
最新稳定版本: http://www.phpsrc.org/eclipse/pti/
Development version: http://www.phpsrc.org/eclipse/pti-dev/
开发版: http://www.phpsrc.org/eclipse/pti-dev/
回答by iteman
We've developed an Eclipse plugin called MakeGoodthat integrates PHPUnitand more testing frameworks with Eclipse PDT.
我们开发了一个名为MakeGood的 Eclipse 插件,它将PHPUnit和更多测试框架与Eclipse PDT集成在一起。
MakeGood is a continuous test runner to run unit tests on Eclipse PDT.
MakeGood provides fast feedback by automated workflows for running tests, tracking failures and errors and fatal errors. This will help developers to do Test Driven Development(TDD) and Continuous Testing.
MakeGood 是一个连续的测试运行器,用于在Eclipse PDT上运行单元测试。
MakeGood 通过自动化工作流程提供快速反馈,用于运行测试、跟踪失败和错误以及致命错误。这将帮助开发人员进行测试驱动开发(TDD) 和持续测试。
For more information, visit our website at: https://github.com/piece/makegood/wiki
如需更多信息,请访问我们的网站:https: //github.com/piece/makegood/wiki
回答by DavidWinterbottom
It is possible to integrate PHPUnit with PDT in a simple way (these settings aren't fully generic but should be a good starting point).
可以通过简单的方式将 PHPUnit 与 PDT 集成(这些设置不是完全通用的,但应该是一个很好的起点)。
- Select the Run > External Tools > External tools configurations
- Create a new program
- Set the Location to point to your executable (/usr/bin/phpunit on linux)
- Set the Working Directory to use the variable ${workspace_loc}
- Set the Arguments to ${resource_path}
- 选择运行 > 外部工具 > 外部工具配置
- 创建一个新程序
- 将位置设置为指向您的可执行文件(Linux 上的 /usr/bin/phpunit)
- 设置工作目录以使用变量 ${workspace_loc}
- 将参数设置为 ${resource_path}
Now select Run > External Tools > PHPUnit to execute the selected test file. This simply executes phpunit and sends STDOUT to the Eclipse terminal. Simple but effective.
现在选择 Run > External Tools > PHPUnit 来执行选定的测试文件。这只是执行 phpunit 并将 STDOUT 发送到 Eclipse 终端。简单但有效。
Subsequently, you can use the icon with a green arrow and red toolbox to run PHPUnit without having to navigate the menus.
随后,您可以使用带有绿色箭头和红色工具箱的图标来运行 PHPUnit,而无需导航菜单。
回答by Pascal MARTIN
(disclaimer: I am absolutely not the developer of the project I'm speaking about here; only a user ^^ (And as I don't know JAVA, it would be quite hard for me to help by contributing code... So this is my way of helping :-) ) )
(免责声明:我绝对不是我在这里谈论的项目的开发者;只是一个用户 ^^(而且由于我不懂 JAVA,我很难通过贡献代码来提供帮助......所以这是我的帮助方式 :-) ) )
There is currently work in progress on that side : a few weeks ago (maybe no more than two weeks), the first of a project of integrating phpunit in Eclipse has been released:
目前这方面的工作正在进行中:几周前(可能不会超过两周),第一个在 Eclipse 中集成 phpunit 的项目已经发布:
What it does:
它能做什么:
- allows to launch phpunit tests from eclipse
- and get some "visual clue" of what is going on
- which is, in some way, better / more user-friendly than the approach proposed by Sebastian on phpunit's wiki.
- 允许从 Eclipse 启动 phpunit 测试
- 并获得一些关于正在发生的事情的“视觉线索”
- 在某种程度上,这比 Sebastian 在 phpunit 的 wiki 上提出的方法更好/更用户友好。
For some kind of screenshot, see http://code.google.com/p/phpunit4eclipse/wiki/j2phpUnitWrapper
对于某种屏幕截图,请参阅http://code.google.com/p/phpunit4eclipse/wiki/j2phpUnitWrapper
Unfortunately, it is not (yet?)developed as an Eclipse plugin:
不幸的是,它还没有(还?)作为 Eclipse 插件开发:
- it is a separate JAVA project, that launches phpunit
- or something like that, as far as I can tell...
- which means :
- not as well integrated in Eclipse as it could
- most important thing is when you double-click on a test class/method, it doesn't get you to that class/method (because the tests' result are shown by the JAVA project, and the test class/method is in another, PHP, project)
- it is still quite hard to install :
- I have not successfully managed to install it in Eclipse PDT
- I have had to install "Eclipse IDE for Java Developers", and, then, install the PDT plugin in this one (which works fine, but is not "easy")
- 它是一个单独的 JAVA 项目,用于启动 phpunit
- 或类似的东西,据我所知......
- 意思是 :
- 没有尽可能好地集成到 Eclipse 中
- 最重要的是当你双击一个测试类/方法时,它不会让你进入那个类/方法(因为测试的结果是由 JAVA 项目显示的,而测试类/方法在另一个中, PHP,项目)
- 安装还是挺难的:
- 我没有成功地在 Eclipse PDT 中安装它
- 我不得不安装“Eclipse IDE for Java Developers”,然后在这个插件中安装 PDT 插件(工作正常,但并不“容易”)
Anyway, this is work in progress, the project is still quite young, and it's only a first step...
无论如何,这是正在进行的工作,项目还很年轻,这只是第一步......
A google group has been created for that project a few time ago: http://groups.google.com/group/phpunit4eclipse-user/
不久前为该项目创建了一个 google 组:http: //groups.google.com/group/phpunit4eclipse-user/
It is currently empty, but I'm sure it would help if some people joined in, gave their thoughts, and why not, helped!
它目前是空的,但我相信如果有人加入并提出他们的想法会有所帮助,为什么不,帮助!
回答by Josh Woodcock
There is defnitely integration for Eclipse PDT and PHPUnit. both PHPSRCand MakeGoodwork well though I am a fan of MakeGood for phpunit phpsrc comes with other goodies like CodeSniffer. I have branched a PHPUnit CodeSniffer Standard on githubthat validates the quality of phpunit tests which I can run with the Eclipse PHP Tools CodeSniffer plugin. This has updates for new phpunit package like setUp and tearDown.
Eclipse PDT 和 PHPUnit 有绝对的集成。PHPSRC和MakeGood都运行良好,尽管我是 phpunit 的 MakeGood 的粉丝 phpsrc 带有其他好东西,如 CodeSniffer。我在 github 上分支了一个PHPUnit CodeSniffer Standard,它验证了我可以使用 Eclipse PHP Tools CodeSniffer 插件运行的 phpunit 测试的质量。这对新的 phpunit 包(如 setUp 和 tearDown)进行了更新。
makes sure there is assertions in tests. Something devs like to leave out when trying to meet code coverage metrics
确保测试中有断言。开发人员在尝试满足代码覆盖率指标时喜欢忽略的东西
Makes sure there is no more than 1 assertion per test. A best practice
确保每个测试不超过 1 个断言。一个最佳实践
Setting up PDT in Eclipse is not straightforward.
在 Eclipse 中设置 PDT 并不简单。
There's a lot of tiny details involved Here's the high level steps.
涉及很多小细节 这是高级步骤。
1 Windows update
2 Install JRE a. http://www.java.com/en/download/index.jsp
3 Create a folder C:\eclipse\workspace
4 Install eclipse pdt
a. http://www.zend.com/en/downloads/thankyou?package=5735 Install xampp –win32-1.81-vc9
a. http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.8.1/xampp-win32-1.8.1-VC9-installer.exe/download6 Install pear phpunit
1 Windows 更新
2 安装 JRE http://www.java.com/en/download/index.jsp
3 创建文件夹 C:\eclipse\workspace
4安装Eclipse PDT
一个。 http://www.zend.com/en/downloads/thankyou?package=5735安装XAMPP -win32-1.81-VC9
一个。 http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.8.1/xampp-win32-1.8.1-VC9-installer.exe/download6 安装梨形phpunit
pear clear-cache
pear upgrade pear
pear update-channels
pear upgrade --alldeps -f
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear channel-discover components.ez.no
pear install --alldeps phpunit/PHPUnit
7 Install Xdebug plugin
a. http://xdebug.org/files/php_xdebug-2.2.1-5.4-vc9.dll
b. Phpinfo settings for xdebug
7 安装Xdebug插件
一种。 http://xdebug.org/files/php_xdebug-2.2.1-5.4-vc9.dll
湾 xdebug 的 Phpinfo 设置
[xdebug]
[调试]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.1-5.4-vc9.dll"
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=9000
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log="C:\xampp\php\logs"
- 8 Install MakeGood a. http://eclipse.piece-framework.com/
- 8 安装 MakeGood http://eclipse.piece-framework.com/
It took me nearly 3 days to finally get everything right so I put together a video tutorial
我花了将近 3 天的时间终于把所有事情都弄好,所以我整理了一个视频教程
Good luck!
祝你好运!
回答by Johan Sydseter
There is a plugin on the Eclipse Marketpalce now called PTI PHP Tool Integration.
Eclipse Marketpalce 上有一个插件,现在称为 PTI PHP Tool Integration。
回答by gabi doroftei
Following @DavidWinterbottom response (Eclipse Indigo):
遵循@DavidWinterbottom 响应(Eclipse Indigo):
Select the Run -> External Tools -> External tools configurations
Create a new program
Set the Location to point to your executable (
/usr/bin/phpunit
on Linux, or path tophpunit.bat
on Windows)Set the Arguments to absolute path to your
phpunit
folder (C:\phpproject\testunit
)
选择运行 -> 外部工具 -> 外部工具配置
创建一个新程序
将位置设置为指向您的可执行文件(
/usr/bin/phpunit
在 Linux 上,或phpunit.bat
在 Windows 上的路径)将参数设置为
phpunit
文件夹的绝对路径(C:\phpproject\testunit
)
I couldn't make get it to using ${project_loc}
or ${project_path}
.
我无法让它使用${project_loc}
或${project_path}
。
回答by philipp
For all using composer on unix like machine (eclipse and xdebug installed):
对于在类 Unix 机器上使用 composer 的所有用户(安装了 eclipse 和 xdebug):
cd <project-root>
ln -s vendor/bin/phpunit phpunit.php
Open eclipse, open run/debug configuration, create a new debug configuration, and select phpunit.php
as file to debug. Continue the rest of the setup as usual, set breakpoints, that's it.
打开eclipse,打开run/debug配置,新建一个调试配置,选择phpunit.php
作为文件进行调试。像往常一样继续其余的设置,设置断点,就是这样。
回答by Nicholas Lemay
I also run PHPUnit as an external tool like DavidWinterbottom proposed.
我还将 PHPUnit 作为外部工具运行,就像 DavidWinterbottom 建议的那样。
One thing I also add depending on the type of project is going into Build Options tab and selecting first options after : "run the builder :". This triggers the unit tests to be run every time you save a file. This is great to get a really quick red-green-refactor feedback loop.
我还根据项目类型添加的一件事是进入“构建选项”选项卡并在“运行构建器:”之后选择第一个选项。每次保存文件时,这都会触发单元测试运行。这对于获得非常快速的红绿重构反馈循环非常有用。
I have posted the entire steps with screenshots here : http://nicholaslemay.blogspot.com/2010/02/using-eclipse-phpunit-as-automatic.html
我在此处发布了带有屏幕截图的整个步骤:http: //nicholaslemay.blogspot.com/2010/02/using-eclipse-phpunit-as-automatic.html