CheckOps home

Tools directory

B

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.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

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

  1. Gherkin for PHP: Cucumber-compatible feature files.
  2. Context classes: Step definitions as PHP methods with attributes.
  3. Suites and tags: Organise and filter scenarios.
  4. Extensions: Mink and others for browser and framework testing.

Pros

  1. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 10 November 2026.
  3. Community: About 4,000 GitHub stars.

Cons

  1. BDD overhead: Valuable mainly when scenarios are shared with stakeholders.
  2. Major upgrade: 4.0 may require changes for 3.x projects.
# 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.

  1. PHP teams practising BDD with business-readable scenarios.
  2. 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.