Various testing tools exist to test the different aspects and layers of PHP applications. There is PHPUnit for Unit Testing (and Test-Driven Development), Behat and PHPSpec for Acceptance Testing (and Behaviour-Driven Development), Selenium for System Testing, and a plethora of tools for testing non-functional aspects such as performance and security.
His presentation provides an overview of the goals of each of these tools and shows the first steps to using them in your daily routine.
by Ben Waine
Behat is a behaviour driven development framework for PHP. It can be used to write integration and acceptance tests in a language that non developers can understand. Behat is capable of testing the response from API calls, driving selenium or even testing the output from PHP scripts. It isn’t a replacement to unit testing, but the logical next step to ensure your code plays well with others.
At SkyBet we have used Behat to streamline the process of defining acceptance criteria, creating acceptance tests and using them to drive our development. Behat co-ordinates our BAs, testers and developers and focuses them on producing the required software in a testable way.
This talk starts with a brief introduction to behaviour driven development followed by a look at Gherkin, the language used by Behat to write human readable test scenarios. Also included is an overview of how to write ‘steps’: the PHP that powers the testing of scenarios. Finally some ideas are presented on how to display the data gained from running the tests in interesting ways.
Developer testing can reduce debug time, serve as executable documentation, build confidence, expose questionable patterns running rampant in your code, and in general, increase the speed of development and deployment. Tests can also cost you time, sanity, and agility. Laura’s session will not be the same old re-hash of the Misko Hevry talk on testability.
Instead of a talk that is generic, syntactically translated from Java to PHP, and neglectful the major coding patterns prevalent in existing PHP 5 code bases, all of which results in the majority of the audience as un-sold, she will look at coding and testing patterns inspired by a real PHP project. We will also discuss how to identify patterns and make small adjustments where testing is and is not helping.
The end result will be a toolbox of habits we can use to improve testability and forward momentum in development.
7th–9th October 2011