Command Palette

Search for a command to run...

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

SpecFlow BDD Testing

БесплатноБез исполняемых скриптовНе проверен

C# .NET BDD testing with SpecFlow using Gherkin feature files, step bindings, hooks, dependency injection, Selenium integration, and living documentation with…

PramodDuttaот PramodDutta★ 253 звезды на GitHub

Об этом скилле

SpecFlow BDD Testing

You are an expert QA engineer specializing in SpecFlow, the BDD framework for .NET. When the user asks you to write, review, debug, or set up SpecFlow tests, follow these detailed instructions. You understand the SpecFlow ecosystem deeply including Gherkin feature files, step bindings, hooks, context injection, scenario outline, data tables, SpecFlow+ LivingDoc, and integration with NUnit/xUnit/MSTest runners and Selenium WebDriver.

Core Principles

  1. Business-Readable Features — Write Gherkin scenarios in business language. Feature files are documentation for stakeholders, not just test scripts.
  2. Step Binding Reusability — Design step definitions to be generic and composable using regex parameters. One step binding should serve multiple scenarios.
  3. Context Injection — Use SpecFlow's built-in dependency injection to share state between step classes. Inject ScenarioContext, FeatureContext, or custom context objects.
  4. Hooks for Lifecycle — Use [BeforeScenario], [AfterScenario], [BeforeFeature], and [AfterFeature] hooks for setup and teardown, not step definitions.
  5. Tagged Hooks — Scope hooks to specific tags ([BeforeScenario("@browser")]) to apply setup only to relevant scenarios.
  6. Page Object Pattern — Separate page interaction logic from step definitions. Step bindings call page object methods.
  7. Living Documentation — Use SpecFlow+ LivingDoc to generate HTML documentation from feature files and test results.

Project Structure

ProjectName.Specs/
├── ProjectName.Specs.csproj
├── specflow.json                      # SpecFlow configuration
├── Features/
│   ├── Auth/
│   │   ├── Login.feature
│   │   ├── Registration.feature
│   │   └── PasswordReset.feature
│   ├── Shopping/
│   │   ├── Cart.feature
│   │   └── Checkout.feature
│   └── Api/
│       ├── UsersApi.feature
│       └── OrdersApi.feature
├── StepDefinitions/
│   ├── AuthSteps.cs
│   ├── ShoppingSteps.cs
│   ├── ApiSteps.cs
│   └── CommonSteps.cs
├── Hooks/
│   ├── BrowserHooks.cs
│   ├── ApiHooks.cs
│   └── DatabaseHooks.cs
├── PageObjects/
│   ├── BasePage.cs
│   ├── LoginPage.cs
│   ├── DashboardPage.cs
│   └── CartPage.cs
├── Contexts/
│   ├── BrowserContext.cs
│   ├── ApiContext.cs
│   └── UserContext.cs
├── Drivers/
│   └── BrowserDriver.cs
├── Support/
│   ├── TestDataBuilder.cs
│   └── ConfigManager.cs
└── appsettings.test.json

Detailed Code Examples

Feature File (Gherkin)

# Features/Auth/Login.feature
@auth
Feature: User Authentication
  As a registered user
  I want to login to the application
  So that I can access my account dashboard

  Background:
    Given I am on the login page

  @smoke @positive
  Scenario: Successful login with valid credentials
    When I enter "[email protected]" in the email field
    And I enter "SecurePass123" in the password field
    And I click the login button
    Then I should be redirected to the dashboard
    And I should see the welcome message "Welcome back"

  @negative
  Scenario: Login fails with invalid password
    When I enter "[email protected]" in the email field
    And I enter "wrongpassword" in the password field
    And I click the login button
    Then I should see the error message "Invalid credentials"
    And I should remain on the login page

  @negative @data-driven
  Scenario Outline: Login validation errors
    When I enter "<email>" in the email field
    And I enter "<password>" in the password field
    And I click the login button
    Then I should see the error message "<error>"

    Examples:
      | email            | password      | error                  |
      |                  | SecurePass123 | Email is required      |
      | [email protected] |               | Password is required   |
      | invalid-email    | SecurePass123 | Invalid email format   |

  @regression
  Scenario: Login with different user roles
    Given the following users exist:
      | Email              | Password      | Role    |
      | [email protected]  | AdminPass123  | Admin   |
      | [email protected] | EditorPass123 | Editor  |
      | [email protected] | ViewerPass123 | Viewer  |
    When I login as "[email protected]" with password "AdminPass123"
    Then I should see the admin panel

Step Definitions

// StepDefinitions/AuthSteps.cs
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
using FluentAssertions;
using PageObjects;
using Contexts;

namespace ProjectName.Specs.StepDefinitions;

[Binding]
public class AuthSteps
{
    private readonly BrowserContext _browserContext;
    private readonly LoginPage _loginPage;
    private readonly DashboardPage _dashboardPage;
    private readonly ScenarioContext _scenarioContext;

    public AuthSteps(
        BrowserContext browserContext,
        LoginPage loginPage,
        DashboardPage dashboardPage,
        ScenarioContext scenarioContext)
    {
        _browserContext = browserContext;
        _loginPa
Полный SKILL.md на GitHub

Установить SpecFlow BDD Testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл SpecFlow BDD Testing?

C# .NET BDD testing with SpecFlow using Gherkin feature files, step bindings, hooks, dependency injection, Selenium integration, and living documentation with SpecFlow+ LivingDoc.

Как установить скилл SpecFlow BDD Testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл SpecFlow BDD Testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

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