views:

298

answers:

4

As far as I can see, PHPUnit is the only serious product in the field at the moment. It is widely used, is integrated into Continuous Integration suites like phpUnderControl, and well regarded.

The thing is, I don't really like working with PHPUnit. I find it hard to set up (PEAR is the only officially supported installation method, and I hate PEAR), sometimes complicated to work with and, correct me if I'm wrong, lacking executability from a web page context (i.e. no CLI, which would really be nice when developing a web app.)

The only competition to I can see is Simpletest, which looks very nice but hasn't seen a new release for almost two years, which tends to rule it out for me - Unit Testing is quite a static field, true, but as I will be deploying those tests alongside web applications, I would like to see active development on the project, at least for security updates and such.

There is a SO question that pretty much confirms what I'm saying: Simple test vs PHPunit Seeing that that is almost two years old as well, though, I think it's time to ask again:

  • Does anybody know any other serious feature-complete unit testing frameworks?

  • Am I wrong in my criticism of PHPUnit?

  • Is there still development going on for SimpleTest?

+7  A: 

First of all : why do you hate PEAR ? Even if there are some bad libraries on pear.php.net, it doesn't mean that the PEAR distribution mecanism is bad...

It deals with dependancies, versionning, updates, ... which is nice, is it not ?


About test Framework :

  • SimpleTest :
    • not maintained anymore ; doesn't evolve -- or, at least, no-one talks about its development, which is generally not quite a good sign, for an OpenSource project !
    • Just go to its website : last release is from 2008-04-08 : two years old !
    • not much of a community, ...
  • Lime (the framework that is/was used by Symfony) :
    • Only used by symfony
    • And even Symfony will stop using it, for version 2.0
  • PHPUnit :
    • The only one that's activelly maintained
    • Used a lot
    • Some community
    • Support
    • Integration with other tools ; be it continuous-integration tools, for instance, or other testing-tools like Selenium
    • One bad thing, in my opinion : you can do functionnal testing with Selenium, of course... But there is no functionnal test mecanism that doesn't use a web-browser
      • Selenium and Lime have such a system
      • Happilly, for Zend Framework projects, there is a Zend_Test component, which does just that

With that, in my opinion, the choice is not hard to make : I'm using PHPUnit ;-)

Pascal MARTIN
Cheers @Pascal, I was expecting things to be this way :) I'm sure PEAR is a good mechanism, but I often work in shared or managed environments with a standard configuration where it's not an option to use, and I often need to create ready-to-ship packages with everything integrated as tightly as possible. Locally I just can't bring myself to using it - I just hate it the instant I see it. Maybe a subjective thing, as I usually like to hand-install and hand-configure libraries. Anyway, thanks for the good rundown. Staying with PHPUnit seems to be the only sensible option. +1.
Pekka
Oh, yes, I see the problem with PEAR, in this case :-( *(I sometimes have this kind of problem on servers that can't access the internet ;-( )* ;;; and yes, PHPUnit seems like the right solution, nowadays...
Pascal MARTIN
+1  A: 

PHPUnit seems to be the most widely used, with the exception of within Symfony projects. Although as Pascal mentions above, in Symfony 2.0 there will be a shift from Lime to PHPUnit as the testing framework. Lime 2 has recently been released and personally I feel that Lime has a lower entry barrier to testing. However as always your mileage may vary, and if you're looking to keep a framework that is well supported, widely used, and in continuous development, PHPUnit is the way to go.

richsage
Yep, this seems to be the state of things. Staying with PHPUnit seems to be the sensible thing to do. Thanks.
Pekka
+2  A: 

I think the criticism is a bit unfair.

PHPUnit is the de-facto standard when it comes to UnitTesting in the PHPWorld. I agree that it is somewhat difficult to work with PHPUnit, but then again, it works like an xUnit framework works. And since it is a framework, it has to be learned like any other framework too. It takes some time, but you get used to it.

Regarding PEAR, it is not PHUnit's fault if you don't like it. PEAR and PHPUnit are separate things. And PEAR is not the only place to get PHPUnit from. There always was the SVN and since Sebastian recently moved from SVN to Git, you can now checkout PHPUnit from there as well instead of using PEAR. PEAR is still the recommened way though, because it can automatically install any dependencies.

Regarding integration, PHPUnit is integrated in Zend Studio for Eclipse, so you can run your UnitTests from your IDE, as well as from the CLI. It does not have a web interface to my knowledge, but why should it? Using it from a webinterface does not make sense for a tool like this, especially when using it in conjunction with a CI server, which will do the tests automatically.

Further reading:

Gordon
@Pekka You're welcome. If there is anything you don't like about PHPUnit, why not tell @s_bergmann on Twitter. Sebastian's german and you can usually meet him at various (un-)conferences, too. He is giving a (commercial) PHPUnit training in DDorf in two weeks. Btw, the link you gave points to this very answer?!
Gordon
@Gordon, good points and thanks for the good reading. I am using PHPUnit from the direct source code already. PHPUnit is indeed hard to beat regarding integration. The desire for a web interface comes partly from wanting a place to press F5 in to see whether the new changeset works - down to preference really. And partly from my plans to build a "production test suite" as discussed here stackoverflow.com/questions/2405825/ but I'm quite sure now this is a totally separate matter, and a unit test suite can't be used as a basis for that.
Pekka
@Gordon I had to delete the comment in order to edit it. The correct link is http://stackoverflow.com/questions/2405825/do-you-have-health-checks-in-your-web-app-or-web-site
Pekka
@Gordon and thanks for the heads up on the training! I can't make it right now but this is good to know, I'll have an eye on it the next time something like that happens in the area.
Pekka