Eclipse PDT 与 PHP 单元?

发布于 2024-07-23 08:44:11 字数 61 浏览 11 评论 0 原文

PHPUnit 与 Eclipse PDT 是否有集成?

如果没有,是否有这样做的计划?

Is there any integration of PHPUnit with Eclipse PDT?

If not, are there any plans to do so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

嗫嚅 2024-07-30 08:44:12

我们开发了一个名为 MakeGood 的 Eclipse 插件,它集成了 PHPUnit 以及更多带有 Eclipse PDT 的测试框架。

MakeGood 是一个连续测试运行程序,用于在 Eclipse PDT 上运行单元测试。

MakeGood 通过自动化工作流程提供快速反馈,用于运行测试、跟踪故障和错误以及致命错误。 这将帮助开发人员进行测试驱动开发 (TDD) 和持续测试< /strong>.


有关更多信息,请访问我们的网站:https://github.com/piece/makegood/wiki

MakeGood 的屏幕截图

We've developed an Eclipse plugin called MakeGood that integrates PHPUnit and more testing frameworks with 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.

For more information, visit our website at: https://github.com/piece/makegood/wiki

A screenshot of MakeGood

戴着白色围巾的女孩 2024-07-30 08:44:12

可以通过简单的方式将 PHPUnit 与 PDT 集成(这些设置并不完全通用,但应该是一个很好的起点)。

  1. 选择“运行”> 外部工具>
    外部工具配置
  2. 创建一个新程序
  3. 将位置设置为指向您的
    可执行文件(/usr/bin/phpunit 上
    linux)
  4. 设置工作目录以使用
    变量 ${workspace_loc}
  5. 将参数设置为
    ${resource_path}

现在选择“运行”>“ 外部工具> PHPUnit 执行选定的测试文件。 这只是执行 phpunit 并将 STDOUT 发送到 Eclipse 终端。 简单但有效。

随后,您可以使用带有绿色箭头和红色工具箱的图标来运行 PHPUnit,而无需导航菜单。

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).

  1. Select the Run > External Tools >
    External tools configurations
  2. Create a new program
  3. Set the Location to point to your
    executable (/usr/bin/phpunit on
    linux)
  4. Set the Working Directory to use the
    variable ${workspace_loc}
  5. Set the Arguments to
    ${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.

Subsequently, you can use the icon with a green arrow and red toolbox to run PHPUnit without having to navigate the menus.

两个我 2024-07-30 08:44:12

Sebastian Bergmann 早在 2006 年就接触过 PDT...但没有明显的结果。
他在博客上的最新条目仅提到 PHPEdit 2.12 和 Zend Studio< /a>.

PDT 方面官方记录的唯一测试框架是 "PDT 测试框架",而且似乎没有积极维护...

所以,不。 短期内似乎没有任何计划主动将 PHPUnit 集成到 PDT 中。

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.

The only testing framework officially documented on the PDT side is the "PDT Testing Framework", and it does not seem actively maintained...

So, no. There does not seem to be any plan to actively integrate PHPUnit in PDT anytime soon.

笙痞 2024-07-30 08:44:12

(免责声明:我绝对不是我在这里所说的项目的开发人员;只是一个用户^^(由于我不懂JAVA,所以我很难通过贡献代码来提供帮助。 .. 所以这是我提供帮助的方式:-) ) )

目前这方面的工作正在进行中:几周前(也许不超过两周),第一个在 Eclipse 中集成 phpunit 的项目已经发布:

它的作用:

  • 允许从 eclipse 启动 phpunit 测试
  • 并获得一些正在发生的事情的“视觉线索”
  • ,这在某种程度上比 Sebastian 提出的方法更好/更用户友好phpunit 的 wiki。

有关某种屏幕截图,请参阅 http://code.google.com/p/phpunit4eclipse /wiki/j2phpUnitWrapper

不幸的是,它还没有作为 Eclipse 插件开发:

  • 它是一个单独的 JAVA 项目,启动 phpunit
    • 或者类似的东西,据我所知......
  • 这意味着:
    • 与 Eclipse 的集成程度不高
    • 最重要的是,当您双击测试类/方法时,它不会让您到达该类/方法(因为测试的结果是由 JAVA 项目显示的,并且测试类/方法在另一个 PHP 项目中)
  • 安装起来仍然很困难:
    • 我尚未成功在 Eclipse PDT 中安装它
    • 我必须安装“Eclipse IDE for Java Developers”,然后在其中安装 PDT 插件(工作正常,但并不“简单”)

无论如何,这是正在进行的工作,该项目还很年轻,这只是第一步......

不久前已为该项目创建了一个 Google 群组:http://groups.google .com/group/phpunit4eclipse-user/

目前,但我相信如果有人加入,给出他们的想法,那将会有所帮助,为什么不呢,帮助!

(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 :-) ) )

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:

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.

For some kind of screenshot, see http://code.google.com/p/phpunit4eclipse/wiki/j2phpUnitWrapper

Unfortunately, it is not (yet?) developed as an Eclipse plugin:

  • 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")

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/

It is currently empty, but I'm sure it would help if some people joined in, gave their thoughts, and why not, helped!

一杯敬自由 2024-07-30 08:44:12

Eclipse PDT 和 PHPUnit 肯定有集成。 PHPSRCMakeGood
尽管我是 phpunit 的 MakeGood 的粉丝,但它工作得很好,phpsrc 还带有其他好东西,如 CodeSniffer。 我在 github 上分支了 PHPUnit CodeSniffer 标准,它验证我可以运行的 phpunit 测试的质量使用 Eclipse PHP 工具 CodeSniffer 插件。 这更新了新的 phpunit 包,例如 setUp 和tearDown。

确保测试中有断言。 开发人员在尝试满足代码覆盖率指标时喜欢忽略的东西
测试中没有断言

确保每个测试的断言不超过 1 个。 最佳实践
太多测试

在 Eclipse 中设置 PDT 并不简单。

涉及很多小细节
这是高级步骤。

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

[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"

我花了将近3天的时间才终于得到一切正常,所以我整理了一个视频教程

祝你好运!

There is defnitely integration for Eclipse PDT and PHPUnit. both PHPSRC and MakeGood
work 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 github that 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.

makes sure there is assertions in tests. Something devs like to leave out when trying to meet code coverage metrics
no assertions in test

Makes sure there is no more than 1 assertion per test. A best practice
too many tests

Setting up PDT in Eclipse is not straightforward.

There's a lot of tiny details involved
Here's the high level steps.

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

[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"

It took me nearly 3 days to finally get everything right so I put together a video tutorial

Good luck!

夜夜流光相皎洁 2024-07-30 08:44:12

Eclipse Marketpalce 上有一个插件,现在称为 PTI PHP Tool Integration。

http://www.phpsrc.org/

There is a plugin on the Eclipse Marketpalce now called PTI PHP Tool Integration.

http://www.phpsrc.org/

我很坚强 2024-07-30 08:44:12

我还像 DavidWinterbottom 提议的那样将 PHPUnit 作为外部工具运行。

我还根据项目类型添加的一件事是进入“构建选项”选项卡并选择“运行构建器:”之后的第一个选项。 这会在您每次保存文件时触发运行单元测试。 这对于获得真正快速的红绿重构反馈循环非常有用。

我已在此处发布了带有屏幕截图的整个步骤: http: //nicholaslemay.blogspot.com/2010/02/using-eclipse-phpunit-as-automatic.html

I also run PHPUnit as an external tool like DavidWinterbottom proposed.

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

故事和酒 2024-07-30 08:44:12

使用 Ant 中的 phpunit 也是可能的,并且 Eclipse 本身就支持 Ant。 只需在目标中添加一个新的 即可,您可以通过 ant 在 Eclipse 中使用 phpunit。

Using phpunit from Ant also is possible, and Ant is natively supported by Eclipse. Simple have a new <exec executable="phpunit"> in a target and voilà, you can use phpunit in eclipse, through ant.

随波逐流 2024-07-30 08:44:12

以下 @DavidWinterbottom 响应 (Eclipse Indigo):

  1. 选择运行 -> 外部工具 -> 外部工具配置

  2. 创建一个新程序

  3. 将位置设置为指向您的可执行文件(Linux 上为/usr/bin/phpunit,或 Windows 上 phpunit.bat 的路径)

  4. 将参数设置为 phpunit 文件夹的绝对路径 (C:\phpproject\testunit)

我无法使用 ${project_loc} 获取它代码> 或 <代码>${project_path}。

Following @DavidWinterbottom response (Eclipse Indigo):

  1. Select the Run -> External Tools -> External tools configurations

  2. Create a new program

  3. Set the Location to point to your executable (/usr/bin/phpunit on Linux, or path to phpunit.bat on Windows)

  4. Set the Arguments to absolute path to your phpunit folder (C:\phpproject\testunit)

I couldn't make get it to using ${project_loc} or ${project_path}.

北渚 2024-07-30 08:44:12

对于所有在类 Unix 机器上使用 Composer 的人(已安装 Eclipse 和 xdebug):

cd <project-root>
ln -s vendor/bin/phpunit phpunit.php

打开 Eclipse,打开运行/调试配置,创建新的调试配置,然后选择 phpunit.php 作为要调试的文件。 像往常一样继续其余的设置,设置断点,就是这样。

For all using composer on unix like machine (eclipse and xdebug installed):

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.

千秋岁 2024-07-30 08:44:12

您已在 Zend Studio 中的 PDT 之上集成了 PHPUnit。 还有一个CE版本。

You have and integration of PHPUnit on top of PDT in Zend Studio. There is a CE edition too.

一生独一 2024-07-30 08:44:12

我在 Eclipse 中尝试了 PHP Unit,但对配置问题不满意。 我切换到 NetBeans PHP IDE。
我推荐 NetBeans PHP IDE 进行 PHP 单元测试。
http://www.netbeans.org/kb/docs/php/phpunit。 html

I tried PHP Unit in Eclipse and was not happy with the configuration issues. I switched to NetBeans PHP IDE.
I recommend NetBeans PHP IDE for PHP Unit testing.
http://www.netbeans.org/kb/docs/php/phpunit.html

沉默的熊 2024-07-30 08:44:11

请参阅 Eclipse 插件 PHP 工具集成 (PTI),它为 Eclipse 提供以下功能的集成:

  • PHP_CodeSniffer
  • PHPUnit
  • PHP Depend
  • PHP Copy /Paste Detector

更新站点(帮助 - 安装软件 - 添加...):

最新稳定版本:http://www.phpsrc.org/eclipse/pti/

开发版本:http://www.phpsrc.org/eclipse/pti-dev/

See Eclipse Plugin PHP Tool Integration (PTI) which provides integration of following features for Eclipse:

  • PHP_CodeSniffer
  • PHPUnit
  • PHP Depend
  • PHP Copy/Paste Detector

Update sites (Help - Install Software - Add ...):

Latest stable release: http://www.phpsrc.org/eclipse/pti/

Development version: http://www.phpsrc.org/eclipse/pti-dev/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文