Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What unit testing in PHP to start [duplicate]

Possible Duplicate:
Simple test vs PHPunit

I'm new to good practices on software development. I need to know with witch testing unit framework should I use. I have see that some people use PHPUnit and others use SimpleTest. What package should I choose for a beginner?

Best Regards,

like image 851
André Avatar asked Jan 07 '11 09:01

André


2 Answers

I'm really really baffled that Simpletest still is considered an alternative to phpunit. Maybe i'm just misinformed but as far as I've seen:

  • PHPUnit is the standard; most frameworks use it (like Zend Framework, Cake, Agavi, even Symfony is dropping their own Framework in Symfony 2 for phpunit).
  • PHPUnit is integrated in every PHP IDE (Eclipse, Netbeans, Zend Stuide, PHPStorm) and works nicely.
    • Simpletest has an eclipse extension for PHP 5.1 (a.k.a. so old that it's on sourceforge) and nothing else.
  • PHPUnit works fine with every continious integration server since it outputs all standard log files for code coverage and test reports.
    • Simpletest does not. While this is not a big problem to start with it will bite you big time once you stop "just testing" and start developing software (Yes that statement is provocative :) Don't take it too seriously).
  • PHPUnit is activly mainted, stable and works great for every codebase, every scenario and every way you want to write your tests.
    • Simpletest is unmaintained, outdated and does not work well with PHP 5.3 (released over a year ago)
  • (Subjective) PHPUnit provides much nicer code coverage reports than Simpletest
    • With PHPUnit you also get these reports inside your IDE (Netbeans, Eclipse, ...)

I've yet to see any argument in favor of Simpletest. It's not even simpler to install since PHPUnit is available via pear:

pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit

and the "first test" looks pretty much the same.

For everything you want to test PHPUnit will have a solution and you will be able to find help pretty much anywhere (SO, #phpunit irc channel on freenode, pretty much every php developer ;) )

Please correct me if i've stated something wrong or forgot something :)

like image 151
edorian Avatar answered Sep 26 '22 17:09

edorian


I started with SimpleTest because the learning curve didn't seem as steep. But it's not maintained, and brings up loads of warnings in PHP5.3, as well as not being able to do everything I wanted. I eventually had to switch to PHPUnit, which was a long process converting my tests. If only I'd started with PHPUnit in the first place!

like image 37
Nathan MacInnes Avatar answered Sep 22 '22 17:09

Nathan MacInnes