TypeScript

Codeception Behaviour Driven (BDD)

Behat was the go-to BDD framework for PHP. Then PHP 7 came out and Behat only supported 5.4. That left a gap.

13 Oct 2023

Codeception Behaviour Driven (BDD)

Behat was the go-to BDD framework for PHP. Then PHP 7 came out and Behat only supported 5.4. That left a gap.

Codeception filled it.

What it does

Codeception is a testing framework for PHP that handles unit tests, functional tests, and acceptance tests in one tool. It's PHPUnit with batteries included — Selenium support, data cleanup, fixtures, and readable test syntax all built in.

Why use it

Two questions from their own FAQ stuck with me:

"Do I really need this?" If you build web apps with forms, links, multiple pages, or APIs, and you want to verify all of it in minutes instead of hours — yes.

"Why not just PHPUnit?" PHPUnit is great for unit tests. But functional testing with Selenium, managing test data, writing XPath selectors — PHPUnit makes all of that painful. Codeception handles it out of the box.

The trade-off

Codeception gives you a single framework for all test levels. BDD-style tests read almost like English. Setup is fast.

The cost: it's opinionated. If your testing needs don't fit Codeception's patterns, you'll fight the framework. And it's PHP-only — if your stack is mixed, you'll need separate tools for non-PHP services.

It works well with frameworks like Laravel and Yii. For raw PHP projects, it's equally straightforward.

Go further
Live cohort on Maven

AI Transformation for Organisational Leaders

For directors, heads of function and founders: eight live evening sessions with Ehsan Gazar and Anoosh Zeighami, ending with a one-page 2027 AI plan for your organisation, built on a real workflow and ready for your leadership team.

$1,495, or $1,045 with code EARLYBIRD until 23 Oct.

View the live cohort

Keep reading