test-anti-patterns
Skill này làm gì
Skill này rà soát code test để tìm các vấn đề thường gặp khiến test thiếu đáng tin hoặc khó bảo trì. Dành cho lập trình viên muốn biết liệu có thể tin vào các test của mình hay không.
Khi nào nên dùng
- ✓Khi test có vẻ đạt mà không kiểm tra điều gì có ý nghĩa.
- ✓Khi test chập chờn, phụ thuộc vào thứ tự chạy, hoặc nuốt ngoại lệ.
- ✓Khi bạn muốn rà soát một tệp hoặc bộ test theo mức nghiêm trọng trước khi tin vào chúng.
Liên kết skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/test-anti-patterns/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy rà soát tệp test của tôi và cho biết test nào không đáng tin hoặc không kiểm tra gì, xếp theo mức độ nghiêm trọng.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent đọc test, đối chiếu với các anti-pattern đã biết cho ngôn ngữ và framework đó, rồi báo cáo các phát hiện từ nghiêm trọng nhất đến ít nghiêm trọng nhấ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.
Test Anti-Pattern Detection
Quick, pragmatic analysis of test code in any supported language for anti-patterns and quality issues that undermine test reliability, maintainability, and diagnostic value.
Language-specific guidance: Read the caller-provided or runtime-listed
test-analysis-extensionscatalog and its matching language file when needed. Do not invoke the reference-only helper. If its files are absent, use the built-in framework rules below.
When to Use
- User asks to review test quality or find test smells
- User wants to know why tests are flaky or unreliable
- User asks "are my tests good?" or "what's wrong with my tests?"
- User requests a test audit or test code review
- User wants diagnostic findings before deciding what to improve
When Not to Use
- User wants to write new tests from scratch (use
code-testing) - User wants direct implementation fixes rather than a diagnostic review (use the relevant write/edit skill)
- User asks to fix swapped
Assert.AreEqualargument order in MSTest (usewriting-mstest-tests) - User asks to convert MSTest
DynamicDatafromIEnumerable<object[]>toValueTuple(usewriting-mstest-tests) - User wants to run or execute tests (use
run-testsfor .NET) - User wants to migrate between test frameworks or versions (use migration skills)
- User wants raw .NET coverage collection (use
run-tests), non-.NET coverage collection or analysis (use native tooling), project-wide .NET coverage/CRAP metrics (usecoverage-analysis), or named-target .NET CRAP (usecrap-score) - User asks whether tests would catch a bug or wants behavioral/pseudo-mutation gaps (use
test-gap-analysis) - User wants test-mix or happy-vs-error-path classification, standardized tagging, or trait/category distributions (use
test-tagging) - User wants a deep formal test smell audit with academic taxonomy and extended catalog (use
test-smell-detection)
Inputs
| Input | Required | Description |
|---|---|---|
| Test scope | No | Test files, classes, directory, or project to analyze. Discover from the current workspace when omitted. |
| Production code | No | The code under test, for context on what tests should verify |
| Specific concern | No | A focused area like "flakiness" or "naming" to narrow the review |
Workflow
Step 1: Detect language and load extension
Resolve the named test path from the current workspace before asking for input.
When no path is supplied, discover test files under the current directory using
the repository manifests and conventional test markers. The skill context's
Base directory is documentation storage, not the user's workspace; never
resolve target files relative to it.
If one reader says a path is missing but a workspace glob/search finds it,
normalize that exact path and retry. Use a shell text reader (sed/cat on
Unix, Get-Content on PowerShell) only for a confirmed reader availability,
transport, or path-normalization failure and only after verifying the canonical
path remains inside the current workspace. Stop on content-exclusion,
permission/policy, workspace-boundary, or unknown failures. Audit any discovered
file that a permitted reader can access; never ask the user to paste it. If
every permitted reader fails, report the exact blocker without bypassing
security boundaries.
Identify the language and framework. Read the matching bundled reference when needed, resolving its filename relative to the supplied catalog. Check only that known reference directory, never installation directories. If unavailable, use the catalog below and report the reference limitation.
Step 2: Gather the test code
Inventory the resolved scope before reading bodies. For one file or class, read that scope directly. For a project or suite, discover test files once, batch independent reads where tools allow, and stop when every discovered test and class-level fixture has a ledger disposition.
Use extension discovery markers when loaded; otherwise use the built-in markers
in this skill (attributes such as [TestClass]/[Fact]/[Test],
test_*.py, *.test.*, *_test.go, *_spec.rb, #[test],
*.Tests.ps1, TEST(...), and TEST_CASE(...)).
Do not read unrelated production code wholesale. Open the production symbol corresponding to every suspicious test needed to decide whether an assertion, transformation, identity contract, or adjacent gap is real. For a systematic facade/surface-area patter
Câu hỏi thường gặp
Nó có sửa test không?
Không. Đây là đánh giá chẩn đoán, còn việc sửa trực tiếp do các skill khác đảm nhận.
Nó hỗ trợ những ngôn ngữ nào?
Nó hỗ trợ nhiều ngôn ngữ và framework, với hướng dẫn tham khảo thêm cho từng loại khi có sẵn.
Nó có chạy test không?
Không. Nó rà soát code test và không thực thi chúng.
Chi tiết
Mô tả gốc của tác giả
Audit a test file or suite; produce a severity-ranked diagnostic report. ALWAYS USE for tests that verify nothing, missing/tautological assertions, swallowed/broad exceptions, flaky/order-dependent tests, duplication, or magic values. Polyglot. DO NOT USE for direct edits: writing-mstest-tests owns supplied MSTest assertions/attributes/lifecycle; code-testing owns new tests. Exclude running tests, migration, assertion metrics (assertion-quality), raw .NET coverage collection (run-tests), non-.NET coverage collection/analysis (native tooling), project-wide .NET coverage/CRAP (coverage-analysis)
repo: dotnet/skills
Độ phổ biến
- Sao GitHub
- 5.8k
- Vị trí xếp hạng
- #14637
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
create-custom-agent
5.8kGiúp agent của bạn tạo file custom agent cho VS Code, với các tool, hướng dẫn và handoff riêng sang agent khác.
create-skill
5.8kGiúp agent của bạn tạo một agent skill mới với tên hợp lệ, mô tả kích hoạt rõ ràng và file SKILL.md đúng tiêu chuẩn.
csharp-scripts
5.8kGiúp agent của bạn chạy một chương trình C# nhỏ dưới dạng một file duy nhất bằng công cụ dòng lệnh .NET, không cần tạo project đầy đủ.
dotnet-pinvoke
5.8kGiúp agent của bạn gọi các thư viện native C hoặc C++ từ .NET đúng cách, gồm khai báo chữ ký, xử lý chuỗi, bộ nhớ và safe handle.
Skill tương tự
test-driven-development
311kDạy agent của bạn viết kiểm thử thất bại trước, xem nó thất bại, rồi viết đoạn mã ngắn nhất để vượt qua trước khi làm bất kỳ tính năng hay bản sửa nào.
verification-before-completion
311kDạy agent của bạn chạy kiểm tra thực tế và đọc kết quả đầu ra trước khi khẳng định một việc, bản sửa hoặc bản build đã hoàn thành hay vượt qua.
migrate-to-shoehorn
310kThay các ép kiểu rủi ro trong tệp kiểm thử bằng thư viện shoehorn, để các bài kiểm thử dùng dữ liệu một phần vẫn qua được kiểm tra kiểu.