Chuyển đến nội dung
Skillpedia
Kiểm thử48k · #4303

cucumber-skill

Skill này làm gì

Công cụ này tạo các bài kiểm thử tự động để kiểm tra phần mềm có hoạt động như mong đợi không. Nó dùng ngôn ngữ Gherkin để mô tả các bước kiểm thử, như “Given I am on the login page”, “When I click the button” và “Then I see a message”.

Khi nào nên dùng

  • ✓Khi bạn muốn kiểm tra chức năng đăng nhập có hoạt động không.
  • ✓Khi bạn cần mô tả cách người dùng tương tác với một website.
  • ✓Khi bạn muốn đảm bảo một tính năng phần mềm không bị hỏng.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/cucumber-skill/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/cucumber-skill/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy tạo một bài kiểm thử Gherkin cho việc đăng nhập thành công của người dùng.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ tạo các file mô tả bài kiểm thử bằng Gherkin, cùng với mã (bằng Java, JavaScript hoặc Ruby) để thực thi các bài kiểm thử này. Điều này giúp đảm bảo phần mềm hoạt động có thể dự đoán được.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Cucumber BDD Skill

When to Use

Use this skill when you need generates Cucumber BDD tests with Gherkin feature files and step definitions in Java, JavaScript, or Ruby. Use when user mentions "Cucumber", "Gherkin", "Feature/Scenario", "Given/When/Then", "BDD". Triggers on: "Cucumber", "Gherkin", "BDD", "Feature file", "Given/When/Then", "step...

Core Patterns

Feature File (Gherkin)

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

  Background:
    Given I am on the login page

  Scenario: Successful login
    When I enter "user@test.com" in the email field
    And I enter "password123" in the password field
    And I click the login button
    Then I should be redirected to the dashboard
    And I should see "Welcome" on the page

  Scenario: Invalid credentials
    When I enter "wrong@test.com" in the email field
    And I enter "wrongpass" in the password field
    And I click the login button
    Then I should see an error message "Invalid credentials"

  Scenario Outline: Login with various users
    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 "<result>"

    Examples:
      | email           | password    | result     |
      | admin@test.com  | admin123    | Dashboard  |
      | user@test.com   | password    | Dashboard  |
      | bad@test.com    | wrong       | Error      |

Step Definitions — Java

import io.cucumber.java.en.*;
import static org.junit.jupiter.api.Assertions.*;

public class LoginSteps {
    private LoginPage loginPage;
    private DashboardPage dashboardPage;

    @Given("I am on the login page")
    public void iAmOnTheLoginPage() {
        loginPage = new LoginPage(driver);
        loginPage.navigate();
    }

    @When("I enter {string} in the email field")
    public void iEnterEmail(String email) {
        loginPage.enterEmail(email);
    }

    @When("I enter {string} in the password field")
    public void iEnterPassword(String password) {
        loginPage.enterPassword(password);
    }

    @When("I click the login button")
    public void iClickLogin() {
        dashboardPage = loginPage.clickLogin();
    }

    @Then("I should be redirected to the dashboard")
    public void iShouldBeOnDashboard() {
        assertTrue(driver.getCurrentUrl().contains("/dashboard"));
    }

    @Then("I should see {string} on the page")
    public void iShouldSeeText(String text) {
        assertTrue(dashboardPage.getPageSource().contains(text));
    }
}

Step Definitions — JavaScript

const { Given, When, Then } = require('@cucumber/cucumber');
const { expect } = require('chai');

Given('I am on the login page', async function() {
  await this.page.goto('/login');
});

When('I enter {string} in the email field', async function(email) {
  await this.page.fill('#email', email);
});

When('I click the login button', async function() {
  await this.page.click('button[type="submit"]');
});

Then('I should see {string} on the page', async function(text) {
  const content = await this.page.textContent('body');
  expect(content).to.include(text);
});

Hooks

import io.cucumber.java.*;

public class Hooks {
    @Before
    public void setUp(Scenario scenario) {
        driver = new ChromeDriver();
    }

    @After
    public void tearDown(Scenario scenario) {
        if (scenario.isFailed()) {
            byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
            scenario.attach(screenshot, "image/png", "failure-screenshot");
        }
        driver.quit();
    }
}

Tags

@smoke
Feature: Login
  @critical @fast
  Scenario: Quick login
    ...

  @slow @regression
  Scenario: Full login flow
    ...
# Run by tag
mvn test -Dcucumber.filter.tags="@smoke"
mvn test -Dcucumber.filter.tags="@smoke and not @slow"

Anti-Patterns

Bad Good Why
UI details in Gherkin Business language Readability
One step per line of code Meaningful business steps Abstraction
No Background for shared steps Use Background DRY
Imperative steps Declarative steps Maintainable

Cloud Execution on TestMu AI

Set environment variables: LT_USERNAME, LT_ACCESS_KEY

Java:

// CucumberHooks.java

…
Câu hỏi thường gặp

Gherkin là gì?

Gherkin là ngôn ngữ đơn giản, dễ đọc với con người, dùng để viết các bước kiểm thử. Nó dùng các từ khóa như “Given”, “When” và “Then” để mô tả hành vi mong đợi.

Định nghĩa bước (Step Definitions) là gì?

Đó là các đoạn mã (bằng các ngôn ngữ như Java, JavaScript hoặc Ruby) cho máy tính biết phải làm gì với từng bước viết trong Gherkin. Chúng kết nối mô tả kiểm thử với hành động thực tế trên phần mềm.

“Tags” dùng để làm gì?

Tags giống như nhãn bạn gắn lên bài kiểm thử, ví dụ “@smoke” hoặc “@regression”. Chúng giúp bạn chọn những bài kiểm thử nào để chạy, ví dụ chỉ chạy các bài quan trọng nhất.

Chi tiết

Mô tả gốc của tác giả

Generates Cucumber BDD tests with Gherkin feature files and step definitions in Java, JavaScript, or Ruby. Use when user mentions \"Cucumber\", \"Gherkin\", \"Feature/Scenario\", \"Given/When/Then\", \"BDD\".

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4303
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự