How widespread, supported, developed is testing in the PHP world? On par with Java? Up there with Ruby/Rails? I Googled and found that testing frameworks exist but I'm wondering if they're widely used.
Do the major PHP IDE's have built-in test runners the way Eclipse's Java tools do or NetBeans's Ruby/Rails tools do? Is testing built into PHP's MVC frameworks as with Rails?
I ask because a group where I work wants to hire someone to develop a PHP app for them. I'm concerned about quality and maintenance as I might be called on to support this thing.
TDD is a development practice while BDD is a team methodology. In TDD, the developers write the tests while in BDD the automated specifications are created by users or testers (with developers wiring them to the code under test.) For small, co-located, developer-centric teams, TDD and BDD are effectively the same.
Test Driven Development is a coding practice where you write a test first then write the code to pass that test, usually in a short iterative cycle. Test Driven Development (TDD), was popularized by Kent Beck. TDD is one of the main techniques followed in his Extreme Programming software development methodology.
In TDD, you write your unit test first, watch it fail, and then implement code changes until the test passes.
Short answer, yes.
There are at least two mature, stand-alone, JUnit style test suites available, named PHPUnit and SimpleTest, respectively.
As far the MVC Frameworks go, Symfony has its own testing framework named lime, Code Igniter has a unit_test library and CakePHP relies on the aforementioned SimpleTest.
I know that Zend Studio has built in support for PHPUnit tests, and both PHPUnit and SimpleTest have command-line runners so integration into any workflow is possible.
The tools are there in the PHP world if a developer wants to take advantage of them, and smart shops do take advantage of them.
The caveats are your par for the course PHP complaints. There are two PHP communities; PHP as a platform for building software, and PHP as a way to interact with a web server, web browser, and database to produce application-like things on the web. It's less a black and white thing and more a continuum; Among those more on the software developer side unit testing and TDD is supported and used as much as it is on any other platform. Among the "cobble together a bunch of stuff I don't understand but still get results people", it's unheard of.
There's a lot of non-framework/custom-framework legacy PHP code around that's difficult to get a useful test harness around. PHP also lends itself easily to patterns that rely on the existence of a browser environment to run. I don't have any evidence to back this up other than my own observations, but a lot of PHP shops that care about testing end up relying on acceptance testing (i.e. Selenium) as a substitute for actual Unit Testing, test-first, etc. development.
In your specific situation, interview the hell out of the developer your group is going to hire.
Ask them what unit testing framework they use
Ask them to describe, in general terms, a real world example of a time they developed a new feature and its supporting tests
Ask them to describe, in general terms, a real world example of a time their tests failed and what they did to resolve the situation
You're less interested in the specific situation they're going to describe and more interested in how comfortable they are discussing their knowledge of code testing in general.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With