Eclipse PDT & PHPUnit?
Asked Answered
N

13

31

Is there any integration of PHPUnit with Eclipse PDT?

If not, are there any plans to do so?

Narra answered 8/6, 2009 at 19:54 Comment(1)
Might I suggest opening a bug report?Jaala
B
5

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.

Bilingual answered 8/6, 2009 at 20:8 Comment(0)
A
43

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/

Aeriela answered 3/7, 2010 at 13:16 Comment(4)
Wow - that was easy. Thanks for this.Grani
unfortunately, I was unable to find a way to actually run the PHP unit tests. Any hints ?Pandiculation
OK! I've installed it.. Now what?Ardeha
Unable to open the site.Halpin
K
22

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

Kerekes answered 2/12, 2009 at 10:55 Comment(0)
E
7

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.

Existential answered 15/7, 2009 at 13:57 Comment(2)
Thanks for the tip! I did it a bit differently: Working Directory="${workspace_loc}\project-name"; Arguments="tests-folder". I also had to add an environment variable ("Environment" tab): PHPBIN="C:\path\to\php.exe"Broadcasting
to debug in PHPUnit , configure xDebug in php.ini and set Environmental variable XDEBUG_CONFIG as idekey=123456Leotaleotard
B
5

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.

Bilingual answered 8/6, 2009 at 20:8 Comment(0)
D
5

(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!

Dinsdale answered 27/7, 2009 at 22:12 Comment(1)
Considering the author of this question has not been on SO for a month and a half, he probably won't get this answer... But, hoppefully, other people will see it, and it'll bring attention to the project ^^Dinsdale
B
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!

Borroff answered 18/2, 2013 at 4:7 Comment(0)
S
2

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

http://www.phpsrc.org/

Selfconsequence answered 6/2, 2012 at 19:59 Comment(0)
A
0

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

Accrescent answered 22/7, 2010 at 2:14 Comment(0)
P
0

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.

Publius answered 26/12, 2010 at 17:41 Comment(0)
N
0

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

Nightlong answered 29/4, 2012 at 23:44 Comment(0)
K
0

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.

Kaffraria answered 3/10, 2016 at 3:56 Comment(0)
C
-1

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

Crocein answered 6/10, 2009 at 19:5 Comment(0)
C
-2

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

Chekiang answered 18/8, 2009 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.