Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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

  1. Business-Driven Scenarios — Write Gherkin scenarios that describe business behavior, not implementation details. Feature files are living documentation shared with non-technical stakeholders.
  2. Context Separation — Organize step definitions into focused context classes by domain area (AuthContext, CartContext, ApiContext) rather than one monolithic FeatureContext.
  3. 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.
  4. Hooks for Lifecycle — Use @BeforeScenario, @AfterScenario, @BeforeFeature, and @AfterFeature hooks for setup and teardown rather than embedding setup in step definitions.
  5. Suite Organization — Define separate suites in behat.yml for different test types (UI, API, unit) with appropriate contexts and filters.
  6. Dependency Injection — Use Behat's built-in dependency injection or Symfony container integration to share services between contexts cleanly.
  7. 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
Полный SKILL.md на GitHub

Установить 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), без исполняемых скриптов.

Похожие скиллы

Сравнить Behat BDD Testing с