dotnet-testing-xunit-project-setup

dotnet-testing-xunit-project-setup is a skill for Claude Code, Codex from kevintsengtw/dotnet-testing-agent-skills. It costs 194 tokens per session (3,951 once invoked), scanned A, original, MIT.

A guide to setting up an xUnit test project in .NET. xUnit is a framework for running automated tests, and the guide shows how to separate application code from its tests.

In plain words
What is it for?
It is for creating a .NET solution with source and test projects, connecting the test project to the code, following naming and folder conventions, and adding coverage collection.
Why use it?
A disorganised test project makes tests harder to find, run, and maintain. The guide provides a consistent solution structure and project references.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-xunit-project-setup
Any agent
npx skills add kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-xunit-project-setup
Clone the repo
git clone --depth 1 https://github.com/kevintsengtw/dotnet-testing-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dotnet-testing-xunit-project-setup

README.md
[![agentmods](https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-xunit-project-setup.svg)](https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-xunit-project-setup)
Your own site
<a href="https://agentmods.dev/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-xunit-project-setup"><img src="https://agentmods.dev/badge/skills/kevintsengtw/dotnet-testing-agent-skills/dotnet-testing-xunit-project-setup.svg" alt="Measured on agentmods" height="20"></a>
Per session 194 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,951 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00194 $0.03951
Opus 5 $0.00097 $0.01975
Sonnet 5 $0.00039 $0.00790
Haiku 4.5 $0.00019 $0.00395

Measured 6d ago against content hash ddd9e23f5a0b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

dotnet-testing-xunit-project-setup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/dotnet-testing-xunit-project-setup/SKILL.md · 420 lines

How it starts

The opening of the file, as written. The whole thing — 420 lines — stays where its author put it; the contents beside it link to each section on GitHub.

xUnit 測試專案設定指南

專案結構最佳實踐

建議的解決方案結構

MyProject/
├── src/                          # 主程式碼目錄
│   └── MyProject.Core/
│       ├── MyProject.Core.csproj
│       ├── Calculator.cs
│       ├── Services/
│       └── Models/
├── tests/                        # 測試程式碼目錄
│   └── MyProject.Core.Tests/
│       ├── MyProject.Core.Tests.csproj
│       ├── CalculatorTests.cs
│       ├── Services/
│       └── Models/
└── MyProject.sln

結構原則:

  1. src 與 tests 分離:清楚區分生產程式碼與測試程式碼
  2. 命名慣例:測試專案名稱為 {主專案名稱}.Tests
  3. 目錄對應:測試專案的資料夾結構應對應主專案的結構
  4. 一對一映射:每個主專案應有對應的測試專案

建立 xUnit 測試專案

方法一:使用 .NET CLI(推薦)

步驟 1:建立解決方案與專案
# 建立解決方案
dotnet new sln -n MyProject

# 建立主專案(類別庫)
dotnet new classlib -n MyProject.Core -o src/MyProject.Core

# 建立測試專案(xUnit 範本)
dotnet new xunit -n MyProject.Core.Tests -o tests/MyProject.Core.Tests

# 將專案加入解決方案
dotnet sln add src/MyProject.Core/MyProject.Core.csproj
dotnet sln add tests/MyProject.Core.Tests/MyProject.Core.Tests.csproj

# 建立專案參考(測試專案參考主專案)
dotnet add tests/MyProject.Core.Tests/MyProject.Core.Tests.csproj reference src/MyProject.Core/MyProject.Core.csproj
步驟 2:安裝程式碼覆蓋率工具
# 切換到測試專案目錄
cd tests/MyProject.Core.Tests

# 安裝 coverlet.collector(用於收集程式碼覆蓋率)
dotnet add package coverlet.collector

方法二:使用 Visual Studio

  1. 建立解決方案

    • File → New → Project
    • 選擇「Blank Solution」
    • 命名為專案名稱
  2. 加入主專案

    • 右鍵解決方案 → Add → New Project
    • 選擇「Class Library」
    • 命名為 MyProject.Core
  3. 加入測試專案

    • 右鍵解決方案 → Add → New Project
    • 搜尋並選擇「xUnit Test Project」
    • 命名為 MyProject.Core.Tests
  4. 設定專案參考

    • 右鍵測試專案 → Add → Project Reference
    • 勾選主專案

xUnit 測試專案的 csproj 設定

標準 xUnit 測試專案 csproj

請參考同目錄下的 templates/xunit-test-project.csproj 範本檔案。

核心相依套件說明:

  1. xunit(2.9.3+)

    • xUnit 測試框架的核心套件
    • 提供 [Fact][Theory] 等測試屬性
    • 包含 Assert 類別與斷言方法
  2. xunit.runner.visualstudio(3.0.0+)

    • Visual Studio Test Explorer 整合
    • 讓測試能在 VS Code、Visual Studio、Rider 中被探索與執行
    • 支援測試結果的即時顯示

Read the full file on GitHub · 420 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 420 lines · 194 tokens per session scan A ddd9e23f5a0b

Subscribe to this mod's changes

dotnet-testing-xunit-project-setup is a skill published in the GitHub repository kevintsengtw/dotnet-testing-agent-skills (28 stars, last pushed 21d ago), licensed MIT. It adds 194 tokens to every session and 3,951 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

inventree-devcontainer-testing

Run the InvenTree Plugin AI Toolkit devcontainer and execute a plugin's test-all.sh. Covers Docker setup, postCreateCommand, server startup, and the lint/unit/integration/frontend-build/E2E layers.

jrobelia/inventree-plugin-ai-toolkit · 49 tokens

author-test

Generate a test given sample. Parameters: C# SDK repository root; Package name: one of Azure.AI.Projects, Azure.AI.Projects.Agents or Azure.AI.Extensions.OpenAI; the sample to use as a starting point for the test.

Azure/azure-sdk-for-net · 68 tokens

test-quality

Write high-quality JUnit 5 tests with AssertJ assertions. Use when user says "add tests", "write tests", "improve test coverage", or when reviewing/creating test classes for Java code.

decebals/claude-code-java · 45 tokens

migrate-xunit-to-xunit-v3

Migrate .NET test projects from xUnit.net v2 to xunit.v3 and fix v3 breaks. Use for package/CPM conversion, OutputType=Exe, preserving the VSTest or MTP runner (including projects currently using YTest.MTP.XUnit2), incompatible TFMs, async void tests, string-to-Type attributes, custom Fact/Theory/BeforeAfterTest…

managedcode/dotnet-skills · 149 tokens

nunit

Write, run, or repair .NET tests that use NUnit. Use when a repo uses NUnit, [Test], [TestCase], [TestFixture], or NUnit3TestAdapter for VSTest or Microsoft.Testing.Platform execution. USE FOR: writing or reviewing NUnit tests; using [Test], [TestCase], [TestFixture], [SetUp], [TearDown] attributes; configuring…

managedcode/dotnet-skills · 146 tokens

crap-score

Calculates CRAP (Change Risk Anti-Patterns) for a named .NET method, class, or file. USE FOR: explicit CRAP calculation or coverage-and-complexity risk within that named target, including which tests to prioritize. DO NOT USE FOR: project-wide coverage/CRAP, plateaus, or project-wide blockers/priorities…

managedcode/dotnet-skills · 99 tokens