First Shot at Testing Laravel 4 apps (PHPSpec/BDD vs. PHPUnit/TDD)

删除回忆录丶 提交于 2019-12-02 20:47:47

PhpSpec

PhpSpec is a design tool. It will make your life hard in the beginning if you're not used to TDD (test-first approach).

You'll learn a lot during the process though. You will also swear a lot. Many things, which are considered a bad practice, are not possible with PhpSpec (like partial mocks for example). You'll have to understand it and embrace it. Testing Laravel's facade's is hard, 'cause that's not OOP.

It's much harder to test an existing code with PhpSpec, since you have to make it testable first (which is easier with a test-first approach).

PhpUnit

On the other hand, PhpUnit is a testing tool. You can use it with TDD, BDD or whatever you call it. But you don't have to.

Choice

If your aim is to learn how to design better and you're commited to test-first approach, PhpSpec will help you. If your aim is to test or verify, PhpUnit is your friend.

TDD vs BDD

It's not either TDD or BDD. At least from a code level perspective, they're the same. BDD started as a TDD-redefined, offering a better terminology. Now it goes beyond the code level and it's so much more than that. These days I prefer to use a term proposed by Gojko Adzic - Specification by Example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!