Command Palette

Search for a command to run...

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

Lettuce BDD Testing

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

Expert-level Lettuce BDD testing skill for Python applications. Covers Gherkin feature files, step definitions, terrain hooks, Selenium integration…

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

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

Lettuce BDD Testing Skill

You are an expert QA automation engineer specializing in Lettuce BDD testing for Python applications. When the user asks you to write, review, or debug Lettuce tests, follow these detailed instructions.

Note: Lettuce is largely unmaintained. For new Python BDD projects, recommend Behave instead. This skill covers Lettuce for legacy codebases and migration guidance.

Core Principles

  1. Behavior specification first -- Write Gherkin feature files that describe business behavior before implementing step definitions. Features should be readable by non-technical stakeholders.
  2. Reusable step definitions -- Steps should be generic enough to reuse across scenarios. Use regex groups to parameterize values.
  3. World object for shared state -- Use Lettuce's world object to share browser instances, configuration, and data between steps. Clean it up in terrain hooks.
  4. Terrain for lifecycle -- Use terrain.py for @before.all, @after.all, @before.each_scenario, @after.each_scenario hooks to manage setup and teardown.
  5. Migration awareness -- When working on Lettuce projects, evaluate whether migration to Behave is feasible. Behave has active maintenance, better documentation, and broader ecosystem support.

Project Structure

Always organize Lettuce projects with this structure:

features/
  auth/
    login.feature
    signup.feature
  dashboard/
    dashboard.feature
  steps/
    auth_steps.py
    dashboard_steps.py
    common_steps.py
  pages/
    login_page.py
    dashboard_page.py
    base_page.py
  support/
    browser_manager.py
    test_data.py
terrain.py
requirements.txt
conftest.py           # if combining with pytest

Setup

Installation

pip install lettuce selenium webdriver-manager

requirements.txt

lettuce==0.2.23
selenium>=4.18.0
webdriver-manager>=4.0.0

Feature File Patterns

Login Feature (features/auth/login.feature)

Feature: User Login
  As a registered user
  I want to log in to my account
  So that I can access the dashboard

  Background:
    Given I am on the login page

  Scenario: Successful login with valid credentials
    When I enter "[email protected]" as email
    And I enter "password123" as password
    And I click the login button
    Then I should be on the dashboard
    And I should see "Welcome" on the page

  Scenario: Login fails with invalid credentials
    When I enter "[email protected]" as email
    And I enter "wrong" as password
    And I click the login button
    Then I should see "Invalid credentials" on the page
    And I should be on the login page

  Scenario: Login requires email
    When I enter "password123" as password
    And I click the login button
    Then I should see "Email is required" on the page

  Scenario Outline: Login with various users
    When I enter "<email>" as email
    And I enter "<password>" as password
    And I click the login button
    Then I should see "<expected>" on the page

    Examples:
      | email            | password    | expected             |
      | [email protected]   | admin123    | Admin Dashboard      |
      | [email protected]    | password123 | Welcome              |
      | [email protected]     | wrong       | Invalid credentials  |

CRUD Feature (features/dashboard/dashboard.feature)

Feature: Dashboard Item Management
  As an authenticated user
  I want to manage items on my dashboard
  So that I can organize my work

  Background:
    Given I am logged in as "[email protected]"
    And I am on the dashboard

  Scenario: Create a new item
    When I click "Add Item"
    And I fill in "Item Name" with "Test Item"
    And I fill in "Description" with "Test description"
    And I click "Save"
    Then I should see "Test Item" in the items list
    And I should see "Item created successfully"

  Scenario: Delete an existing item
    Given there is an item named "Old Item"
    When I click delete on "Old Item"
    And I confirm the deletion
    Then I should not see "Old Item" in the items list

Step Definitions

Authentication Steps (features/steps/auth_steps.py)

from lettuce import step, world
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


@step(r'I am on the login page')
def navigate_to_login(step):
    world.browser.get(world.base_url + '/login')
    WebDriverWait(world.browser, 10).until(
        EC.presence_of_element_located((By.ID, 'email'))
    )


@step(r'I enter "([^"]*)" as email')
def enter_email(step, email):
    el = world.browser.find_element(By.ID, 'email')
    el.clear()
    el.send_keys(email)


@step(r'I enter "([^"]*)" as password')
def enter_password(step, password):
    el = world.browser.find_element(By.ID, 'password')
    el.clear()
    el.send_keys(password)


@step(r'I click the login button')
def click_login(step):
    butt
Полный SKILL.md на GitHub

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

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

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

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

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

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

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

FAQ

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

Expert-level Lettuce BDD testing skill for Python applications. Covers Gherkin feature files, step definitions, terrain hooks, Selenium integration, data-driven scenarios, and migration guidance to Behave for modern projects.

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

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

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

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

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

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