开发者

Anyone knows something like RSPec for PHP? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but 开发者_Python百科this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜