scaffold-dotnet-test-project
Skill này làm gì
Skill này tạo một dự án test .NET còn thiếu, hoặc sửa cách kết nối của dự án có sẵn, để các test được đưa vào solution và build tìm thấy. Dành cho lập trình viên có test chạy được trên máy nhưng không được CI tìm thấy.
Khi nào nên dùng
- ✓Khi một dự án test có sẵn bị bỏ khỏi bộ lọc solution hoặc biến mất khỏi solution.
- ✓Khi CI tìm thấy 0 test dù các test chạy được khi chạy trực tiếp.
- ✓Khi cần tạo một dự án test mới và kết nối nó với dự án production.
Liên kết skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/scaffold-dotnet-test-project/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
“Test của tôi chạy được trên máy nhưng CI tìm thấy 0 test. Bạn có thể sửa cách kết nối dự án test trong solution không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent đọc các tệp solution và bộ lọc, tìm phần còn thiếu, thực hiện thay đổi nhỏ nhất để build tìm thấy test, rồi kiểm tra kết quả.
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.
Scaffold or Repair a .NET Test Project
Create the smallest missing test container or repair only the missing wiring. The goal is test discovery through the repository's real build entry point, not a preferred solution layout.
Repository overlay
For every repository-scoped task where read-only file inspection is allowed,
check .agents/skill-overlays/dotnet-test/scaffold-dotnet-test-project.md at
the repository root before any other discovery. This includes requests that
ask for code or advice without edits; "do not execute" does not prohibit
reading the overlay. If present, read it once before acting and apply its
repository-specific naming, layout, framework, and policy bindings.
Before applying it, require its frontmatter to declare
core: dotnet-test/scaffold-dotnet-test-project, binding-revision: "1", and
mode: extend. If any value is missing or different, report the mismatch and
continue using this skill's portable guidance without applying the overlay.
Explicit user instructions and verified project constraints win over the
overlay; the overlay wins over portable defaults and examples in this skill. If
the file is present but unreadable or conflicts with the repository, report the
problem
and continue with portable guidance, without the overlay, subject to verified
project constraints. If it is absent, continue normally. Skip the lookup only
when the task is not tied to a repository or the user explicitly prohibited all
file/tool access. An overlay cannot expand tool permissions or the task's scope.
Route the Request
Inspect the repository before editing, then choose exactly one path:
| Repository state | Action | Do not do |
|---|---|---|
| No suitable test project | Create one bounded project, reference the production project, and register it | Create a project per source project |
Test project exists but lacks the required ProjectReference |
Add only that reference and verify direct plus entry-point execution | Scaffold another project or rewrite tests |
Test project passes directly but is absent from .sln, .slnx, or .slnf |
Register the existing project in the exact entry point CI uses | Recreate the project or switch solution formats |
| Suitable project, reference, and requested entry point are already correct | Leave the workspace unchanged; use code-testing if test methods are requested |
Normalize or replace working files |
An existing project is suitable when its target framework can reference the production project and its purpose matches the requested layer. A different preferred name is not a reason to create a duplicate.
No-op is a required outcome. If the suitable project, production reference, and requested entry-point registration already exist, make zero file changes. Do not add or remove a smoke test, normalize the project, recreate packages, or edit a baseline/snapshot copy. Report the existing paths and stop.
Workflow
1. Establish the repository contract
Start from the task's current working directory. The skill context's Base directory is where these instructions live, not the user's repository. Never
search parent temporary directories or treat the skill installation as the
workspace. If the expected files are not visible, confirm the current directory
before concluding that a project is absent.
Anchor every edit and validation command to the repository path named by the user or established from the current directory. If similarly named fixtures, solutions, or copied trees exist, do not edit or validate one as a substitute for the requested tree. Before changing a solution artifact, record its exact path; after changing it, list that same artifact immediately and require the test project to appear before proceeding.
Read only enough to determine:
- the production project and requested test scope;
- the command and
.sln,.slnx,.slnf, or project graph used by CI; - whether a suitable test project exists, what it references, and where it is registered;
- the neighboring test framework, runner, target framework, nullable and implicit-usings conventions; and
- whether package or SDK versions come from
Directory.Packages.props,Directory.Build.props,global.json, or an MSBuild SDK declaration.
If the user reports that a test project passes directly but solution-level discovery finds nothing, treat that as registration evidence. Inspect the entry point before considering project creation.
2. Create only when
Câu hỏi thường gặp
Nó có viết test mới không?
Không. Nó chỉ thiết lập hoặc sửa phần khung dự án test và cách kết nối, không đụng đến code test.
Nó hỗ trợ những framework nào?
Hỗ trợ xUnit, NUnit và MSTest, và có thể dùng quản lý package tập trung khi repository đang dùng.
Nó có thay đổi cấu trúc solution của tôi không?
Skill hướng tới thay đổi nhỏ nhất hoạt động được với điểm vào build thực tế của repository.
Chi tiết
Mô tả gốc của tác giả
MUST USE when an existing .NET test project was excluded from a .slnf/CI solution filter, disappeared from .sln/.slnx discovery, or lost its production ProjectReference; also for requests to set up, create, reuse, add, register, include, or repair a test project. Handles "tests pass directly but CI discovers zero", exact solution wiring, xUnit/NUnit/MSTest, and central packages. DO NOT USE to only author tests in an already-wired project (code-testing), run tests, migrate, or correct MSTest syntax/configuration without changing project or CI files (writing-mstest-tests).
repo: dotnet/skills
Độ phổ biến
- Sao GitHub
- 5.8k
- Vị trí xếp hạng
- #14636
- 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.