csharp-xunit
Skill2 starsChanged 27 days agoMITView on GitHub
Get best practices for XUnit unit testing, including data-driven tests
4 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- github/awesome-copilotword for word, first seen Oct 25, 2026
- PracticalSwan/agent-skillsedited, first seen Oct 19, 2026
- itsfatduck/optimizerDuckword for word, first seen Oct 8, 2026
- RorroRojas3/maf-agentsedited, first seen Sep 10, 2026
Other versions4 projects use a version of this.
Word for word · 2
- github/awesome-copilot★ 41k100% same
- itsfatduck/optimizerDuck★ 11k100% same
Edited · 2
- PracticalSwan/agent-skills★ 2246% same
- RorroRojas3/maf-agents★ 0100% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository192 other files it gives its agents.
- clickhouse-architecture-advisor/AGENTS.mdAGENTS.md
- clickhouse-best-practices/AGENTS.mdAGENTS.md
- unsafe-checker/AGENTS.mdAGENTS.md
- alertmanager-querySkill
- analyzing-range-distributionSkill
- analyzing-schema-change-storage-riskSkill
- argocdSkill
- aspire-configurationSkill
- aspire-integration-testingSkill
- aspire-service-defaultsSkill
- auditing-cloud-cluster-securitySkill
- auditing-table-statisticsSkill
- benchmarking-transaction-patternsSkill
- cepthSkill
- chdb-datastoreSkill
- chdb-sqlSkill
- clickhouse-architecture-advisorSkill
- clickhouse-best-practicesSkill
- clickhousectl-cloud-deploySkill
- clickhousectl-local-devSkill
- cockroachdb-sqlSkill
- coding-guidelinesSkill
- configuring-audit-loggingSkill
- configuring-ip-allowlistsSkill
- configuring-log-exportSkill
- configuring-private-connectivitySkill
- configuring-sso-and-scimSkill
- create-technical-architecture-documentSkill
- csharp-mstestSkill
- csharp-tunitSkill
- designing-application-transactionsSkill
- designing-multi-region-applicationsSkill
- domain-cliSkill
- domain-cloud-nativeSkill
- domain-embeddedSkill
- domain-fintechSkill
- domain-iotSkill
- domain-mlSkill
- domain-webSkill
- dotnet-aot-wasmSkill
- dotnet-aspire-patternsSkill
- dotnet-benchmarkdotnetSkill
- dotnet-blazor-authSkill
- dotnet-blazor-componentsSkill
- dotnet-blazor-patternsSkill
- dotnet-blazor-testingSkill
- dotnet-channelsSkill
- dotnet-ci-benchmarkingSkill
- dotnet-cli-architectureSkill
- dotnet-cli-distributionSkill
- dotnet-cli-packagingSkill
- dotnet-cli-release-pipelineSkill
- dotnet-containersSkill
- dotnet-cryptographySkill
- dotnet-csharp-dependency-injectionSkill
- dotnet-csharp-modern-patternsSkill
- dotnet-csharp-nullable-reference-typesSkill
- dotnet-csharp-source-generatorsSkill
- dotnet-maui-doctorSkill
- dotnet-maui-doctorSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
31 rules. About 0 are common, 11 are distinctive, and 20 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
20
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use a separate test project with naming convention [ProjectName].Tests
- Very specific: line 14
Create test classes that match the classes being tested (e.g., CalculatorTests for Calculator)
- Very specific: line 15
Use .NET SDK test commands: dotnet test for running tests
- Distinctive: line 19
No test class attributes required (unlike MSTest/NUnit)
- Very specific: line 20
Use fact-based tests with [Fact] attribute for simple tests
- Distinctive: line 21
Follow the Arrange-Act-Assert (AAA) pattern
- Very specific: line 23
Use constructor for setup and IDisposable.Dispose() for teardown
- Very specific: line 24
Use IClassFixture<T> for shared context between tests in a class
- Very specific: line 25
Use ICollectionFixture<T> for shared context between multiple test classes
- Distinctive: line 29
Keep tests focused on a single behavior
- Distinctive: line 30
Avoid testing multiple behaviors in one test method
- Distinctive: line 31
Use clear assertions that express intent
- Very specific: line 38
Use [Theory] combined with data source attributes
- Very specific: line 39
Use [InlineData] for inline test data
- Very specific: line 40
Use [MemberData] for method-based test data
- Very specific: line 41
Use [ClassData] for class-based test data
- Very specific: line 42
Create custom data attributes by implementing DataAttribute
- Distinctive: line 43
Use meaningful parameter names in data-driven tests
- Very specific: line 47
Use Assert.Equal for value equality
- Very specific: line 48
Use Assert.Same for reference equality
- Very specific: line 49
Use Assert.True/Assert.False for boolean conditions
- Very specific: line 50
Use Assert.Contains/Assert.DoesNotContain for collections
- Very specific: line 51
Use Assert.Matches/Assert.DoesNotMatch for regex pattern matching
- Very specific: line 52
Use Assert.Throws<T> or await Assert.ThrowsAsync<T> to test exceptions
- Distinctive: line 53
Use fluent assertions library for more readable assertions
- Distinctive: line 57
Consider using Moq or NSubstitute alongside XUnit
- Distinctive: line 59
Use interfaces to facilitate mocking
- Distinctive: line 60
Consider using a DI container for complex test setups
- Very specific: line 65
Use [Trait("Category", "CategoryName")] for categorization
- Distinctive: line 66
Use collection fixtures to group tests with shared dependencies
- Very specific: line 67
Consider output helpers (ITestOutputHelper) for test diagnostics
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
XUnit Best Practices
Your goal is to help me write effective unit tests with XUnit, covering both standard and data-driven testing approaches.
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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

