
Csharp Xunit
- 4 installs
- 7 repo stars
- Updated August 2, 2026
- practicalswan/agent-skills
csharp-xunit is a Claude Code skill for ai & agent building.
About
Provides xUnit conventions and data-driven test patterns for .NET code. A .NET developer uses it when writing or reviewing C# unit tests.
- xUnit testing patterns
- Data-driven test guidance
Csharp Xunit by the numbers
- 4 all-time installs (skills.sh)
- Ranked #1,631 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/practicalswan/agent-skills --skill csharp-xunitAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 4 |
|---|---|
| repo stars | ★ 7 |
| Last updated | August 2, 2026 |
| Repository | practicalswan/agent-skills ↗ |
How do I helps with ai & agent building tasks.?
xUnit testing patterns and data-driven test guidance for writing or reviewing .NET unit tests.
Who is it for?
A solo builder working on ai & agent building tasks who needs structured help with csharp xunit.
Skip if: Teams with no ai & agent building needs, or anyone wanting a generic chat assistant without this specific workflow.
When should I use this skill?
When you need to helps with ai & agent building tasks., or when csharp-xunit is a claude code skill for ai & agent building.
What you get
Structured output aligned to csharp-xunit: csharp-xunit, AI & Agent Building.
Files
XUnit Best Practices
Optimized for current .NET SDK releases, C# 12+, xUnit 2.x, and FluentAssertions 6+.
Your goal is to help me write effective unit tests with XUnit, covering both standard and data-driven testing approaches.
- Leverage native parallel subagent dispatch and 200k+ context windows where available.
Anti-Patterns
- Treating fixtures as hidden setup: Readers lose sight of the behavior under test when too much state is shared implicitly.
- Asserting only the happy path: Unit tests miss the contract if failure and edge cases are not explicit.
- Using vague test names: A failing test should explain the broken behavior before anyone opens the body.
Verification Protocol
Before claiming "skill applied successfully":
1. Pass/fail: The Csharp Xunit implementation names the target runtime, framework version, and affected files. 2. Pass/fail: Build, lint, test, or equivalent local validation is run for the changed surface. 3. Pass/fail: Edge cases for errors, dependency drift, and environment differences are addressed or explicitly out of scope. 4. Pressure-test scenario: Apply the workflow to a change that passes happy-path tests but fails one boundary condition. 5. Success metric: Zero untested success claims; every implementation claim maps to a command or artifact.
Before and After Example
// Before
[Fact]
public async Task SavesOrder()
{
var id = await service.SaveAsync(order);
Assert.True(id > 0);
}
// After
[Fact]
public async Task SaveAsync_WhenOrderIsValid_PersistsAndReturnsId()
{
// Arrange
var order = new Order("ORD-42", 3);
// Act
var id = await service.SaveAsync(order);
// Assert
id.Should().BeGreaterThan(0);
}Moves from a vague assertion to an explicit Arrange-Act-Assert flow with a descriptive name.
Project Setup
- Use a separate test project with naming convention
[ProjectName].Tests - Reference Microsoft.NET.Test.Sdk, xunit, and xunit.runner.visualstudio packages
- Create test classes that match the classes being tested (e.g.,
CalculatorTestsforCalculator) - Use .NET SDK test commands:
dotnet testfor running tests
Test Structure
- No test class attributes required (unlike MSTest/NUnit)
- Use fact-based tests with
[Fact]attribute for simple tests - Follow the Arrange-Act-Assert (AAA) pattern
- Name tests using the pattern
MethodName_Scenario_ExpectedBehavior - Use constructor for setup and
IDisposable.Dispose()for teardown - Use
IClassFixture<T>for shared context between tests in a class - Use
ICollectionFixture<T>for shared context between multiple test classes
Standard Tests
- Keep tests focused on a single behavior
- Avoid testing multiple behaviors in one test method
- Use clear assertions that express intent
- Include only the assertions needed to verify the test case
- Make tests independent and idempotent (can run in any order)
- Avoid test interdependencies
Data-Driven Tests
- Use
[Theory]combined with data source attributes - Use
[InlineData]for inline test data - Use
[MemberData]for method-based test data - Use
[ClassData]for class-based test data - Create custom data attributes by implementing
DataAttribute - Use meaningful parameter names in data-driven tests
Assertions
- Use
Assert.Equalfor value equality - Use
Assert.Samefor reference equality - Use
Assert.True/Assert.Falsefor boolean conditions - Use
Assert.Contains/Assert.DoesNotContainfor collections - Use
Assert.Matches/Assert.DoesNotMatchfor regex pattern matching - Use
Assert.Throws<T>orawait Assert.ThrowsAsync<T>to test exceptions - Use fluent assertions library for more readable assertions
Mocking and Isolation
- Consider using Moq or NSubstitute alongside XUnit
- Mock dependencies to isolate units under test
- Use interfaces to facilitate mocking
- Consider using a DI container for complex test setups
Test Organization
- Group tests by feature or component
- Use
[Trait("Category", "CategoryName")]for categorization - Use collection fixtures to group tests with shared dependencies
- Consider output helpers (
ITestOutputHelper) for test diagnostics - Skip tests conditionally with
Skip = "reason"in fact/theory attributes
Common Pitfalls
- Using vague test names: It becomes hard to tell which behavior failed without opening the test body.
- Hiding setup inside fixtures: Large shared fixtures make tests brittle and obscure the actual cause of a failure.
- Skipping async-specific assertions: Awaitable code often fails in different ways than synchronous code and needs explicit coverage.
<!-- PORTABILITY:START -->
Cross-Client Portability
This skill is written to stay usable across GitHub Copilot, Claude Code, Codex, and Gemini CLI.
- GitHub Copilot: keep the folder in a Copilot-visible skill or plugin path, or wrap the workflow as project instructions if the host does not support portable skill folders directly.
- Claude Code: keep the folder in a local skills directory or a compatible plugin or marketplace source.
- Codex: install or sync the folder into
$CODEX_HOME/skills/<skill-name>and restart Codex after major changes. - Gemini CLI: this repository generates a project command named
/skills:csharp-xunitfrom this skill. Rebuild commands withpython scripts/export-gemini-skill.py csharp-xunitand then run/commands reloadinside Gemini CLI.
<!-- PORTABILITY:END -->
<!-- MCP:START -->
MCP Availability And Fallback
Preferred MCP Server: None required
- Fallback prompt: "Use the XUnit Best Practices skill without MCP. Rely on the local
SKILL.md, bundled references or scripts, and manual verification. Show the exact commands, evidence, and final checks you used before concluding." - If the current host does not expose a matching server, use the bundled references, scripts, native toolchain, and manual workflow already described in this skill.
- Treat direct local verification, rendered output, logs, tests, or screenshots as the fallback evidence path before completion.
<!-- MCP:END -->
Related Skills
- dotnet-best-practices: Use it when the workflow also needs .NET architecture and maintainability guidance.
- test-driven-development: Use it when the workflow also needs test-first implementation and regression safety.
- code-quality: Use it when the workflow also needs two-stage review (spec compliance first, then code quality), maintainability, and refactoring guidance.
- systematic-debugging: Use it when the workflow also needs root-cause debugging before proposing fixes.
Changelog
[2026-04-25] - Version 1.2 Verification Protocol Refresh
Added
- Added a
Verification Protocolsection with skill-specific pass/fail checks, one pressure-test scenario, and a measurable success metric. - Added guidance to leverage native parallel subagent dispatch and 200k+ context windows where available.
Changed
- Updated
SKILL.mdfrontmatter toversion: "1.2"andlast_updated: 2026-04-25. - Reframed activation guidance toward symptom -> action triggers and standardized two-stage review wording where applicable.
[2026-04-24] - Version 1.1 Refresh
Changed
- Updated the SKILL frontmatter version to
1.1for the 2026-04-24 catalog refresh. - Added an "Optimized for ..." note at the top so the guidance is anchored to current platform versions.
All notable changes to the csharp-xunit skill will be documented in this file.
[2026-04-24] - Skill Refresh
Changed
- Standardized the SKILL frontmatter with version metadata, last-updated date, tags, and a concise catalog description.
- Reformatted the portability and MCP guidance with a preferred server line, a copy-paste fallback prompt, and consistent bullet lists.
- Added a catalog-standard Anti-Patterns section and refreshed the Related Skills links at the end of the skill.
- Added an explicit before-and-after example, current-version targeting note, and a Common Pitfalls section for modern xUnit usage.
[2026-04-04] - Initial Import and Portability Upgrade
Added
- Imported this skill from
https://github.com/github/awesome-copilotatskills/csharp-xunit. - Added cross-client portability guidance for GitHub Copilot, Claude Code, Codex, and Gemini CLI.
- Added the repo-standard MCP or no-MCP fallback guidance for this skill.
Changed
- Rewrote the frontmatter description to match the activation-focused style used by the maintained catalog.
Tested
- Validated
SKILL.mdfrontmatter and Gemini command export readiness withpython scripts/validate-skills.py.
Related skills
FAQ
What does csharp-xunit do?
csharp-xunit is a Claude Code skill for ai & agent building.
When should I use csharp-xunit?
When you need to helps with ai & agent building tasks., or when csharp-xunit is a claude code skill for ai & agent building.
What are the main capabilities?
csharp-xunit; AI & Agent Building; AI-coding skill.