PHP developers start their careers by testing new features and functions they had just written in the browser window one by one, and when something went wrong they were clueless about what to do. Writing tests for our code can spare precious debugging time and hours of headache.
The main difference between test-driven and behaviour-driven testing is in the syntax of the testing code: TDD uses proper PHP code in the testing files, while BDD uses human-readable sentences that describe the behaviour of each feature and can be understood by non-technical stakeholders too.
Here is the list of 12 Best PHP Automated Test Frameworks to simplify your workflow.
1. Selenium
Selenium automates browsers. it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well. Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.
2. PHPUnit
PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks. It can be used via the command line, and it provides us with a handy TestCase class that we can extend according to our needs. PHPUnit also allows developers to use pre-written assertion methods to assert that the app behaves a certain way.
3. Behat
Behat is a behavior-driven development (BDD) framework that lets you write human-readable story-driven code that describes how your application should function. It’s quick and easy to get started with, and easy to learn.
4. Kahlan
Kahlan is a full-featured Unit & BDD test framework a la RSpec/JSpec which uses a describe-itsyntax and moves testing in PHP one step forward. Kahlan allows to stub or monkey patch your code directly like in Ruby or JavaScript without any required PECL-extentions. It has a small code base, it’s said to be about 10 times smaller than PHPUnit, and it has loads of features that provide us with an extensible and customizable testing workflow.
5. Atoum
Atoum is an intuitive and modern PHP testing framework that allows us to run unit tests. It simplifies test development, and as it’s a young framework it makes use of some newer capabilities that were introduced in PHP 5.3 (it can‘t be used with older PHP versions) to provide us with a quick and easy-to-understand testing process.
6. Codeception
Codeception doesn’t only enable us to write Unit Tests, but also Functional and Acceptance Tests. These two latter tests the PHP app as a whole with all features tied together, not as units. Codeception allows us to enable and configure different modules according to our development needs. It’s integrated with many PHP development frameworks such as Symfony2, Laravel4, Yii, Phalcon, and the Zend Framework. This means that we can use a PHP automation testing framework and a PHP development framework together to establish a superefficient development workflow.
7. SimpleTest
SimpleTest is an easy-to-use PHP unit testing framework in Test-Driven Development style, it can be seen as an alternative for PHPUnit. SimpleTest supports SSL, forms, proxies, frames and basic authentication, and it allows us to test common PHP tasks quickly.
8. Storyplayer
Storyplayer is a full-stack testing framework that makes it possible to write end-to-end tests for an entire platform. Storyplayer has support for creating and destroying test environments on demand. It follows the TDD testing approach, and allows us to write functional tests that can check an application as a whole.
9. Peridot
Peridot is a lightweight, extensible testing framework for PHP. It features anevent-driven architecture that allows testers to easily customize the framework via plugins and reporters. Peridot uses the describe-it syntax to establish a clear and readable testing language that clearly describes how our application code should behave.
10. PHO
Pho is BDD test framework for PHP, inspired by Jasmine and RSpec. Features a familiar syntax, and a watch command to automatically re-run specs during development. It can also be extended with custom matchers and reporters.
11. Mockery
Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succint API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL).
12. PHP Specs
PHPSpec also follows the behaviour-driven testing approach, but its other subtype called SpecBDD. With PHPSpec we need to write the specifications first that describe how the application code will behave.