davorminchorov's avatar

How do you choose a testing framework?

Hey,

I am just curious how are you people choosing a testing framework? I know 5.1 has some great testing capabilities out of the box but there are other frameworks too (and some of them even use the same tools with different APIs)

We have PHPUnit, PHPSpec, Behat, Codeception, Laravel's package out of the box and probably many many more.

Do you have any specific reasons for using one tool over the other? Also, are there any upsides and downsides of using different testing frameworks or all of them can do the job just fine (in general)?

0 likes
4 replies
JeffreyWay's avatar
Level 59

You'll likely use a few of the tools you referenced at the same time. It depends upon the project. As an example, for the Laracasts source, I use PHPSpec, PHPUnit, and Laravel's application testing features.

I've used Codeception and Behat before as well. A lot of this boils down to trying them out, and seeing what works for you.

  • Behat puts a lot of energy into conversation. So if you like the idea of translating conversations with your business/customer/client into executable code, you might want to check it out.

  • Codeception is more terse. There's no syntax like Gherkin, but you can still effectively test the same things. In fact, Codeception can handle unit tests, all the way up to acceptance tests.

  • PHPSpec is exclusively for designing objects. For integration testing, or anything higher level, you won't use it.

  • PHPUnit is great for designing objects, too, but it can also be used for basically everything. If you're just getting into this world, start here.

5 likes
bugsysha's avatar

Just pick what @JeffreyWay uses. That way you'll ensure that you'll probably see a video about it :D

2 likes

Please or to participate in this conversation.