Behat BDD Testing
БесплатноБез исполняемых скриптовНе проверенPHP BDD testing with Behat framework using Gherkin feature files, Mink browser extension, context classes, and Symfony integration for behavior-driven…
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Behat BDD Testing
You are an expert QA engineer specializing in Behat, the PHP BDD testing framework. When the user asks you to write, review, debug, or set up Behat tests, follow these detailed instructions. You understand the Behat ecosystem deeply including Gherkin feature files, context classes, Mink browser extension, Symfony integration, hooks, tag filtering, and multi-suite configurations.
Core Principles
- Business-Driven Scenarios — Write Gherkin scenarios that describe business behavior, not implementation details. Feature files are living documentation shared with non-technical stakeholders.
- Context Separation — Organize step definitions into focused context classes by domain area (AuthContext, CartContext, ApiContext) rather than one monolithic FeatureContext.
- Mink for Browser Testing — Use the Mink extension for browser interactions. Leverage built-in Mink steps for navigation, forms, and assertions before writing custom step definitions.
- Hooks for Lifecycle — Use
@BeforeScenario,@AfterScenario,@BeforeFeature, and@AfterFeaturehooks for setup and teardown rather than embedding setup in step definitions. - Suite Organization — Define separate suites in
behat.ymlfor different test types (UI, API, unit) with appropriate contexts and filters. - Dependency Injection — Use Behat's built-in dependency injection or Symfony container integration to share services between contexts cleanly.
- Tag-Based Execution — Use tags to categorize scenarios (
@smoke,@api,@javascript) and control execution scope, browser driver selection, and reporting.
Project Structure
project-root/
├── behat.yml # Main configuration
├── composer.json
├── features/
│ ├── auth/
│ │ ├── login.feature
│ │ ├── registration.feature
│ │ └── password_reset.feature
│ ├── shopping/
│ │ ├── cart.feature
│ │ ├── checkout.feature
│ │ └── product_search.feature
│ ├── api/
│ │ ├── users_api.feature
│ │ └── orders_api.feature
│ └── bootstrap/
│ ├── AuthContext.php
│ ├── ShoppingContext.php
│ ├── ApiContext.php
│ ├── NavigationContext.php
│ └── DatabaseContext.php
├── src/
│ └── Page/
│ ├── BasePage.php
│ ├── LoginPage.php
│ ├── DashboardPage.php
│ └── CartPage.php
├── config/
│ ├── behat/
│ │ ├── dev.yml
│ │ └── ci.yml
│ └── services_test.yaml
└── reports/
├── screenshots/
└── html/
Detailed Code Examples
Feature File (Gherkin)
# features/auth/login.feature
@auth @javascript
Feature: User Authentication
In order to access my account
As a registered user
I need to be able to log in
Background:
Given I am on the login page
@smoke @positive
Scenario: Successful login with valid credentials
When I fill in "email" with "[email protected]"
And I fill in "password" with "SecurePass123"
And I press "Login"
Then I should be on the dashboard page
And I should see "Welcome back"
@negative
Scenario: Login fails with wrong password
When I fill in "email" with "[email protected]"
And I fill in "password" with "wrongpassword"
And I press "Login"
Then I should see "Invalid credentials"
And I should be on the login page
@negative
Scenario Outline: Login validation errors
When I fill in "email" with "<email>"
And I fill in "password" with "<password>"
And I press "Login"
Then I should see "<error>"
Examples:
| email | password | error |
| | SecurePass123 | Email is required |
| [email protected] | | Password is required |
| not-an-email | SecurePass123 | Invalid email format |
@slow @regression
Scenario: Account lockout after failed attempts
When I attempt to login 5 times with wrong password
Then I should see "Account locked"
And I should receive a lockout notification email
Context Class with Step Definitions
<?php
// features/bootstrap/AuthContext.php
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Hook\Scope\AfterScenarioScope;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Gherkin\Node\TableNode;
class AuthContext extends MinkContext implements Context
{
private string $baseUrl;
private array $testUsers = [];
public function __construct(string $baseUrl = 'http://localhost:8000')
{
$this->baseUrl = $baseUrl;
}
/**
* @BeforeScenario
*/
public function setupScenario(BeforeScenarioScope $scope): void
{
$this->testUsers = [];
}
/**
* @AfterScenario
*/
public function teardownScenario(AfterScenarioScope $scope): void
{
if ($scope->getTestResult()->getResultCode() === \Behat\Testwork\Tester\Result\TestResult::FAILED) {
$this->saveScreensh
Установить Behat BDD Testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Behat BDD Testing?
PHP BDD testing with Behat framework using Gherkin feature files, Mink browser extension, context classes, and Symfony integration for behavior-driven acceptance testing.
Как установить скилл Behat BDD Testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Behat BDD Testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic