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

go-testing

Skill này làm gì

Skill này hướng dẫn AI của bạn khi viết hoặc rà soát test bằng ngôn ngữ Go. Dành cho lập trình viên Go muốn test tập trung và đáng tin cậy, kể cả test giao diện terminal.

Khi nào nên dùng

  • ✓Khi bạn viết test cho một hàm Go có nhiều trường hợp đầu vào.
  • ✓Khi bạn kiểm thử một giao diện người dùng terminal được xây dựng bằng Bubbletea.
  • ✓Khi bạn cần test file golden hoặc test chạm đến hệ thống file.

Liên kết skill

https://github.com/Gentleman-Programming/gentle-ai/blob/main/internal/assets/skills/go-testing/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/Gentleman-Programming/gentle-ai/blob/main/internal/assets/skills/go-testing/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

“Viết test Go dạng bảng cho parser này, bao gồm cả các trường hợp lỗi.”

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

Cách hoạt động

Skill chọn mẫu test phù hợp với mục tiêu, như test theo bảng cho hàm hoặc cập nhật model trực tiếp cho giao diện terminal. Nó giữ test có tính xác định và bỏ qua các test bên ngoài chậm ở chế độ short.

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.

Activation Contract

Load this skill when writing or reviewing Go tests, adding coverage, testing Bubbletea/TUI flows, using teatest, or updating golden files.

Hard Rules

  • Prefer table-driven tests for multiple cases; use t.Run(tt.name, ...).
  • Test behavior and state transitions, not implementation trivia.
  • Use t.TempDir() for filesystem tests; never rely on a real home directory.
  • Keep integration tests skippable with testing.Short() when they run external commands or slow flows.
  • For Bubbletea, test Model.Update() directly for state changes; use teatest only for interactive flows.
  • Golden files must be deterministic; update only through the repo's -update path and rerun tests without -update.
  • Use small mocks/interfaces around system or command execution boundaries.

Decision Gates

Target Test pattern
Pure function or parser Table-driven unit test.
Error behavior Explicit success and failure cases.
File operations t.TempDir() plus focused assertions.
TUI state transition Direct Model.Update() call with tea.Msg.
Full TUI interaction teatest.NewTestModel().
Rendered output Golden file test.
Real external command Integration test; skip in -short.

Execution Steps

  1. Identify behavior under test and the smallest public boundary that proves it.
  2. Choose the test pattern from the decision gate.
  3. Name cases by scenario, not input mechanics.
  4. Assert outputs, errors, state, and side effects explicitly.
  5. Run the narrow package test first, then the relevant broader suite.
  6. For golden updates: run with -update, inspect diff, then rerun without -update.

Output Contract

Report test files changed, scenarios covered, commands executed, golden files updated, and any skipped integration scope.

References

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

File golden là gì?

Đó là một đầu ra mong đợi được lưu lại để test so sánh, và skill yêu cầu nó phải xác định.

Nó kiểm thử giao diện terminal thế nào?

Nó kiểm tra trực tiếp các thay đổi trạng thái, và chỉ dùng teatest cho các luồng tương tác đầy đủ.

Test có dùng thư mục home thật không?

Không. Skill nói phải dùng thư mục tạm và không bao giờ dựa vào thư mục home thật.

Chi tiết

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

Trigger: Go tests, go test coverage, Bubbletea teatest, golden files. Apply focused Go testing patterns.

repo: Gentleman-Programming/gentle-ai

Độ phổ biến

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