Skip to main content
skill CX Codex

behat-skill — Claude Code skill: Behat BDD tests for PHP

Generates Behat BDD tests for PHP with Gherkin scenarios and MinkContext for browser checks. Creates feature files, custom contexts and behat.yml config.

MIT 216 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill behat-skill -a claude-code
Open on GitHub

What behat-skill does

The skill writes Behat BDD tests: feature files with Gherkin scenarios (Given I am on "/login", When I fill in "email", Then I should see "Dashboard"), custom contexts with annotated steps (@When I login as :email with password :password) and behat.yml with Mink extension settings. Uses built-in MinkContext steps for navigation, forms and assertions or creates new ones in LoginContext, ApiContext. Connects Selenium via wd_host and builds config for remote execution on LambdaTest with LT_USERNAME and LT_ACCESS_KEY environment variables.

Inside the skill — samples from reference/playbook.md: suite setup, Scenario Outline with tables, Page Object pattern, hooks for screenshots on test failure, formatters for HTML reports, CI/CD config for GitHub Actions with MySQL and Selenium, a 14-item practices checklist and a table of 12 common issues. Requires Composer packages behat/behat, behat/mink-extension, behat/mink-selenium2-driver and initialization via ./vendor/bin/behat --init.

What it helps with

  • write a Gherkin login scenario with redirect check
  • create a custom context with a step for an API request
  • set up behat.yml for LambdaTest execution
  • add a hook to roll back transactions after each scenario
  • generate a Page Object with form elements map

Example prompts for the agent

  • Create a feature file features/checkout.feature with a cart item check
  • Write an ApiContext with a step @When I send POST to :endpoint with JSON
  • Set up behat.yml to run Chrome on Windows 11 via LambdaTest

How to install behat-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill behat-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/behat-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/behat-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about behat-skill

How to install behat-skill in Claude Code?

Run npx skills add LambdaTest/agent-skills --skill behat-skill -a claude-code, the skill will land in ~/.claude/skills/behat-skill/SKILL.md.

What does behat-skill do?

Generates Behat BDD tests: Gherkin scenarios, custom contexts with annotated steps, behat.yml config for MinkExtension and Selenium, hooks for screenshots, Page Object classes and CI/CD setup.

What does behat-skill require?

Composer packages behat/behat, behat/mink-extension, behat/mink-selenium2-driver. For remote execution on LambdaTest — LT_USERNAME and LT_ACCESS_KEY environment variables.

Source text

SKILL.md · MIT
---
name: behat-skill
description: >
  Generates Behat BDD tests for PHP with Gherkin feature files and MinkContext
  for browser testing. Use when user mentions "Behat", "PHP BDD", "Mink",
  "behat.yml". Triggers on: "Behat", "PHP BDD", "Mink", "behat.yml",
  "FeatureContext PHP".
languages:
  - PHP
category: bdd-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# Behat BDD Skill

## Core Patterns

### Feature File (features/login.feature)

```gherkin
Feature: User Login
  As a user I want to log in

  Scenario: Successful login
    Given I am on "/login"
    When I fill in "email" with "[email protected]"
    And I fill in "password" with "password123"
    And I press "Login"
    Then I should see "Dashboard"
    And I should be on "/dashboard"

  Scenario: Invalid credentials
    Given I am on "/login"
    When I fill in "email" with "[email protected]"
    And I fill in "password" with "wrong"
    And I press "Login"
    Then I should see "Invalid credentials"
```

### Custom Context (features/bootstrap/LoginContext.php)

```php
<?php
use Behat\MinkExtension\Context\MinkContext;
use Behat\Behat\Context\Context;

class LoginContext extends MinkContext implements Context
{
    /**
     * @When I login as :email with password :password
     */
    public function iLoginAs(string $email, string $password): void
    {
        $this->visit('/login');
        $this->fillField('email', $email);
        $this->fillField('password', $password);
        $this->pressButton('Login');
    }

    /**
     * @Then I should see the dashboard
     */
    public function iShouldSeeTheDashboard(): void
    {
        $this->assertSession()->addressEquals('/dashboard');
        $this->assertSession()->pageTextContains('Welcome');
    }

    /**
     * @Then the response time should be under :ms milliseconds
     */
    public function responseUnder(int $ms): void
    {
        // Custom performance assertion
    }
}
```

### Built-in MinkContext Steps

```gherkin
# Navigation
Given I am on "/path"
When I go to "/path"
When I reload the page

# Forms
When I fill in "field" with "value"
When I select "option" from "select"
When I check "checkbox"
When I uncheck "checkbox"
When I press "button"
When I attach the file "path" to "field"

# Assertions
Then I should see "text"
Then I should not see "text"
Then I should be on "/path"
Then the response status code should be 200
Then the "field" field should contain "value"
Then I should see an "css-selector" element
Then print current URL
```

### behat.yml

```yaml
default:
  suites:
    default:
      contexts:
        - LoginContext
        - Behat\MinkExtension\Context\MinkContext
  extensions:
    Behat\MinkExtension:
      base_url: 'http://localhost:3000'
      sessions:
        default:
          selenium2:
            browser: chrome
            wd_host: 'http://localhost:4444/wd/hub'
```

### Tags

```bash
./vendor/bin/behat --tags=@smoke
./vendor/bin/behat --tags="@smoke&&~@slow"
```

## Setup: `composer require --dev behat/behat behat/mink-extension behat/mink-selenium2-driver`
## Init: `./vendor/bin/behat --init`

### Cloud Execution on TestMu AI

Set environment variables: `LT_USERNAME`, `LT_ACCESS_KEY`

```yaml
# behat.yml
default:
  extensions:
    Behat\MinkExtension:
      base_url: 'https://your-app.com'
      selenium2:
        wd_host: 'https://hub.lambdatest.com/wd/hub'
        capabilities:
          browser: 'chrome'
          extra_capabilities:
            'LT:Options':
              user: '%env(LT_USERNAME)%'
              accessKey: '%env(LT_ACCESS_KEY)%'
              build: 'Behat Build'
              name: 'Behat Test'
              platformName: 'Windows 11'
              video: true
              console: true
              network: true
```
## Run: `./vendor/bin/behat` or `./vendor/bin/behat features/login.feature`

## Deep Patterns

See `reference/playbook.md` for production-grade patterns:

| Section | What You Get |
|---------|-------------|
| §1 Project Setup | behat.yml with suites, Mink extension, profiles, project structure |
| §2 Feature Files | Gherkin with Scenario Outline, Background, TableNode data |
| §3 Context Classes | Step definitions, dependency injection, API context, assertions |
| §4 Hooks | BeforeSuite/Scenario/Step, screenshot on failure, transaction rollback |
| §5 Page Objects | Page Object pattern with elements map, reusable components |
| §6 LambdaTest Integration | Remote Selenium config, cloud browser profiles |
| §7 Custom Formatters | HTML report formatter, result collection |
| §8 CI/CD Integration | GitHub Actions with MySQL, Selenium, JUnit reports |
| §9 Debugging Table | 12 common problems with causes and fixes |
| §10 Best Practices | 14-item BDD testing checklist |

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
specflow-skill Drafts SpecFlow BDD suites for C#/.NET: Gherkin feature files plus the step bindings behind them. Useful when a project already runs on NUnit or xUnit. CX Codex +1 223installs serenity-bdd-skill serenity-bdd-skill is a Claude Code skill that creates Java BDD tests with Serenity and the Screenplay pattern. It activates for requests about Serenity, @Steps, or Serenity reports. CX Codex +1 223installs rspec-skill Generates RSpec tests in Ruby with describe/context/it blocks, matchers, let/before hooks, and mocking. Works with Claude Code, Codex, Cursor, GitHub Copilot, and other editors. CX Codex +1 222installs gauge-skill Generates Gauge Markdown test specifications and step implementations in Java, Python, JavaScript, or Ruby. CX Codex +1 218installs testunit-skill testunit-skill generates Test::Unit tests for Ruby projects: xUnit-style classes, assert methods and fixtures. Fits codebases already running on test-unit rather than RSpec. CX Codex +1 213installs testcafe-skill Generate TestCafe end-to-end tests in JavaScript or TypeScript, from login flows to selector checks. The skill covers local runs and TestMu AI Cloud. CX Codex +1 212installs geb-skill This skill generates browser automation tests in Groovy using Geb and Spock. It provides page object patterns and jQuery-like selectors for e2e testing. CX Codex +1 211installs capybara-skill Generates acceptance tests for web apps using Capybara and RSpec. Use it to automate clicks, form fills, and page assertions in Ruby-based E2E suites. CX Codex +1 210installs

Project sponsors

Companies that keep this analytics open