CheckOps
Behat
Behat is an MIT-licensed behaviour-driven development framework for PHP that runs Gherkin feature files against PHP context classes, often paired with Mink for browser testing.
- Unit Testing
- Php
- Open source
- Free
- Bdd
- Integration Testing
- Unit testing
- Integration testing
- End-to-end & functional
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
Behat is the PHP implementation of Cucumber-style behaviour-driven development. Teams describe features in Gherkin (Feature, Scenario, Given/When/Then), and Behat matches each step to a method in a PHP context class. It is widely used for acceptance testing of PHP applications, including Drupal and Symfony projects.
Step definitions are methods annotated with step patterns (using PHP attributes such as #[Given('...')] or docblock annotations), with Turnip-style placeholders or regular expressions. Hooks run before and after suites, features, scenarios and steps; contexts can be split per domain and configured per suite in behat.yml; tags filter scenarios; and output formatters include pretty, progress and JUnit. Extensions extend Behat, most notably Mink, which provides browser emulation and real-browser drivers for web acceptance tests. Behat v4.0.0, a new major version, was released on 28 September 2026; check the upgrade notes when moving from 3.x.
The source code is at Behat/Behat on GitHub under the MIT licence, with about 4,000 stars; the most recent commit was on 10 November 2026.
Features
- Gherkin for PHP: Cucumber-compatible feature files.
- Context classes: Step definitions as PHP methods with attributes.
- Suites and tags: Organise and filter scenarios.
- Extensions: Mink and others for browser and framework testing.
Pros
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 10 November 2026.
- Community: About 4,000 GitHub stars.
Cons
- BDD overhead: Valuable mainly when scenarios are shared with stakeholders.
- Major upgrade: 4.0 may require changes for 3.x projects.
Usage and Links (Example)
# features/cart.feature
Feature: Cart
Scenario: Add an item
Given the cart is empty
When I add "apple" to the cart
Then the cart should contain 1 item
use Behat\Behat\Context\Context;
use Behat\Step\{Given, When, Then};
final class FeatureContext implements Context
{
private Cart $cart;
#[Given('the cart is empty')]
public function emptyCart(): void { $this->cart = new Cart(); }
#[When('I add :item to the cart')]
public function add(string $item): void { $this->cart->add($item); }
#[Then('the cart should contain :count item')]
public function count(int $count): void { assert($this->cart->count() === $count); }
}
Resources:
Pricing
Behat is free and open source under the MIT licence.
Recommended for?
- PHP teams practising BDD with business-readable scenarios.
- Drupal and Symfony projects with acceptance test suites.
Conclusion
Behat is the standard BDD framework for PHP, mature and extensible, now entering a new major version.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with Behat side by side.
CCucumberCucumber is the open-source BDD tool that runs Gherkin feature files against step definitions. It is not CucumberStudio.Compare with Behat
CCodeceptionCodeception is an MIT-licensed full-stack PHP testing framework covering unit, functional, API and acceptance tests in one tool, with modules for WebDriver, REST, databases and frameworks such as Laravel and Symfony.Compare with Behat
Pphpspecphpspec is an MIT-licensed specification-oriented BDD toolset for PHP that helps you design classes by writing specs first, with code generation for missing classes and methods.Compare with Behat
PPestPest is an MIT-licensed PHP testing framework built on PHPUnit with an expressive, closure-based API; Pest 5 (PHP 8.4+, PHPUnit 13) adds the Tia engine, an agent plugin, evals, PHPStan and Rector support.Compare with Behat
Bbehavebehave is a BSD-licensed behaviour-driven development framework for Python that runs Gherkin feature files with step definitions written in Python.Compare with Behat
RReqnrollReqnroll is a BSD-3-Clause .NET port of Cucumber based on the SpecFlow code base, running Gherkin scenarios with MSTest, NUnit, xUnit or TUnit on .NET Framework 4.6.2+ through .NET 10.Compare with Behat