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
npx skills add LambdaTest/agent-skills --skill behat-skill -a claude-codeWhat 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.ymlfor 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.featurewith a cart item check - Write an
ApiContextwith a step@When I send POST to :endpoint with JSON - Set up
behat.ymlto 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-code2Manually: put the files in place
~/.claude/skills/behat-skill/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/behat-skill/
1Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill behat-skill -a codex2Manually: put the files in place
.agents/skills/behat-skill/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill behat-skill -a cursor2Manually: put the files in place
.cursor/skills/behat-skill/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install LambdaTest/agent-skills behat-skill2Manually: put the files in place
.github/skills/behat-skill/SKILL.md1Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill behat-skill -a gemini-cli2Platform CLI
gemini skills install https://github.com/LambdaTest/agent-skills --path behat-skillManually: put the files in place
.devin/skills/behat-skill/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill behat-skill -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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