Anyone knows something like RSPec for PHP? [closed]
RSPec is a great ruby test framework (for test driven development), anyone knows something like rspec but, for PHP?
PHPSpec is a Behaviour-Driven Development framework for php. I've not used it myself yet, though, so I can't comment on it specifically.
Behat! Built on top of Symfony 2 components. Syntactically, not as nice as Ruby implementation but still get the benefits of BDD.
I just stumbled upon it myself and haven't used it yet. From a glance, it looks like it's using closures (which it would need to do to work like RSpec/Cucumber) which is a PHP 5.3 addition.
http://behat.org/
PHPUnit is the de-facto standard for UnitTesting in PHP.
It can do BD Testing to a limited extent:
The PHPUnit_Extensions_Story_TestCase class adds a story framework that faciliates the definition of a Domain-Specific Language for Behaviour-Driven Development. Inside a scenario, given(), when(), and then() each represent a step. and() is the same kind as the previous step. The following methods are declared abstract in PHPUnit_Extensions_Story_TestCase and need to be implemented:
runGiven(&$world, $action, $arguments) ... runWhen(&$world, $action, $arguments) ... runThen(&$world, $action, $arguments) ...
Edit: An more sophisticated alternative might be Cucumber with Behat
There are few of RSpec clones in PHP.
PHPSpec Spectrum
Also there is an original testing framework Codeception
If you are only intrested in the output of tests, you could use phpunit-progress which makes your tests results look exactly like RSpecs' results.
Selenium is another one worth to mention here.
精彩评论