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

tdd-workflow

Skill này làm gì

Skill này hướng dẫn một chu kỳ phát triển theo test (TDD) theo phong cách trường phái London, trong đó các phụ thuộc được mock trước. Skill dành cho lập trình viên muốn xây tính năng từng bước với test dẫn đường.

Khi nào nên dùng

  • ✓Khi bạn muốn xây một tính năng theo hướng test trước, từ bên ngoài vào trong.
  • ✓Khi bạn muốn một quy trình đỏ, xanh, tái cấu trúc rõ ràng cho một hành vi mới.
  • ✓Khi bạn muốn kiểm tra kết quả test cuối cùng trước khi coi tác vụ là xong.

Liên kết skill

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-testgen/skills/tdd-workflow/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/ruvnet/ruflo/blob/main/plugins/ruflo-testgen/skills/tdd-workflow/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 xây phép tính giảm giá theo hướng test trước, bắt đầu bằng một test lỗi cho dịch vụ định giá đã được mock.”

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

Cách hoạt động

Skill viết một test lỗi với các phụ thuộc được mock, chạy nó để thấy nó lỗi đúng lý do, rồi viết mã đơn giản nhất để vượt qua và tái cấu trúc. Trước khi báo thành công, skill chạy test mục tiêu và test hồi quy, rồi ghi lại kết quả thực tế.

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.

Follow the TDD London School (mock-first) approach:

  1. Write the failing test first -- define expected behavior with mocked dependencies
  2. Run the test -- confirm it fails for the right reason
  3. Implement minimal code -- make the test pass with the simplest solution
  4. Refactor -- clean up while keeping tests green
  5. Repeat -- add the next behavior

Before starting: mcp__plugin_ruflo-core_ruflo__hooks_pre-task({ description: "TDD: FEATURE_NAME" }) Before reporting the outcome, run the final target tests and the regression suite after the last edit. Record the actual commands, exit codes, whether tests ran, and failing test names. The initial red test is expected during TDD; only the final validation determines success.

Call mcp__plugin_ruflo-core_ruflo__hooks_post-task with the observed result, including when the task is abandoned or validation is interrupted. Set completed, targetTestsRan, and regressionTestsRan to true only when observed; use null for missing exit codes. Skipped or unrun validation is not success. Never substitute an expected result for an observed one.

The following example maps those observations to the hook input (tool-call notation):

const success = completed && targetTestsRan && regressionTestsRan
  && targetExitCode === 0 && regressionExitCode === 0;
mcp__plugin_ruflo-core_ruflo__hooks_post-task({
  taskId: "tdd-FEATURE",
  success,
  storeResults: true,
  task: JSON.stringify({
    feature: "FEATURE",
    targetCommand, targetExitCode, targetTestsRan,
    regressionCommand, regressionExitCode, regressionTestsRan,
    failingTestNames,
    failureReason: success ? null : failureReason
  })
});

On failure, report success: false and the failing test names in task. If the runner failed before identifying tests, or the task was abandoned, state that reason instead of inventing test names.

Principles:

  • Mock external dependencies at boundaries
  • Test behavior, not implementation
  • One assertion per test when possible
  • Descriptive names: should [behavior] when [condition]
Câu hỏi thường gặp

Test lỗi ban đầu có phải là vấn đề không?

Không. Nguồn nói test đỏ đầu tiên là điều được mong đợi trong phương pháp này. Chỉ kiểm tra xác nhận cuối cùng mới quyết định thành công.

Thế nào là thành công?

Cả test mục tiêu lẫn bộ test hồi quy đều phải thực sự chạy và vượt qua. Test bị bỏ qua không được tính là thành công.

Skill có ghi lại kết quả không?

Có. Skill báo cáo kết quả tác vụ cho các hook bộ nhớ cùng với kết quả quan sát được.

Chi tiết

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

TDD London School workflow -- mock-first, outside-in test development

repo: ruvnet/ruflo

Độ phổ biến

Sao GitHub
81k
Vị trí xếp hạng
#1701
Giấy phép
MIT
Cập nhật
2/11/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ự