dotnet-test-frameworks
Skill9 starsChanged 6 months agoMITView on GitHub
Reference data for .NET test framework detection patterns, assertion APIs, skip annotations, setup/teardown methods, and common test smell indicators across MSTest, xUnit, NUnit, and TUnit. DO NOT USE directly — loaded by test analysis skills (test-anti-patterns, exp-test-smell-detection, exp-assertion-quality, exp-test-maintainability, exp-test-tagging) when they need framework-specific lookup tables.
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- cli-e2e-testingSkill
- crap-scoreSkill
- detect-static-dependenciesSkill
- dotnet-livecharts2Skill
- dotnet-modern-csharp-editorconfigSkill
- dotnet-test-frameworksSkill
- filter-syntaxSkill
- generate-testability-wrappersSkill
- migrate-static-to-wrapperSkill
- mtp-hot-reloadSkill
- platform-detectionSkill
- run-testsSkill
- test-anti-patternsSkill
- writing-mstest-testsSkill
- cli-e2e-testingSkill
- crap-scoreSkill
- detect-static-dependenciesSkill
- dotnet-livecharts2Skill
- dotnet-modern-csharp-editorconfigSkill
- filter-syntaxSkill
- generate-testability-wrappersSkill
- migrate-static-to-wrapperSkill
- mtp-hot-reloadSkill
- platform-detectionSkill
- run-testsSkill
- test-anti-patternsSkill
- writing-mstest-testsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 60
When a test uses try/catch to verify exceptions, suggest the framework-native alternative:
≈ “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
.NET Test Framework Reference
Language-specific detection patterns for .NET test frameworks (MSTest, xUnit, NUnit, TUnit).
Test File Identification
| Framework | Test class markers | Test method markers |
| MSTest | [TestClass] | [TestMethod], [DataTestMethod] |
| xUnit | (none — convention-based) | [Fact], [Theory] |
| NUnit | [TestFixture] | [Test], [TestCase], [TestCaseSource] |
| TUnit | [ClassDataSource] | [Test] |
Assertion APIs by Framework
| Category | MSTest | xUnit | NUnit |
| Equality | Assert.AreEqual | Assert.Equal | Assert.That(x, Is.EqualTo(y)) |
| Boolean | Assert.IsTrue / Assert.IsFalse | Assert.True / Assert.False | Assert.That(x, Is.True) |
| Null | Assert.IsNull / Assert.IsNotNull | Assert.Null / Assert.NotNull | Assert.That(x, Is.Null) |
| Exception | Assert.Throws<T>() / Assert.ThrowsExactly<T>() | Assert.Throws<T>() | Assert.That(() => ..., Throws.TypeOf<T>()) |
| Collection | CollectionAssert.Contains | Assert.Contains | Assert.That(col, Has.Member(x)) |
| String | StringAssert.Contains | Assert.Contains(str, sub) | Assert.That(str, Does.Contain(sub)) |
| Type | Assert.IsInstanceOfType | Assert.IsAssignableFrom | Assert.That(x, Is.InstanceOf<T>()) |
| Inconclusive | Assert.Inconclusive() | skip via [Fact(Skip)] | Assert.Inconclusive() |
| Fail | Assert.Fail() | Assert.Fail() (.NET 10+) | Assert.Fail() |
Third-party assertion libraries: Should* (Shouldly), .Should() (FluentAssertions / AwesomeAssertions), Verify() (Verify).
Sleep/Delay Patterns
| Pattern | Example |
| Thread sleep | Thread.Sleep(2000) |
| Task delay | await Task.Delay(1000) |
| SpinWait | SpinWait.SpinUntil(() => condition, timeout) |
Skip/Ignore Annotations
| Framework | Annotation | With reason |
| MSTest | [Ignore] | [Ignore("reason")] |
| xUnit | [Fact(Skip = "reason")] | (reason is required) |
| NUnit | [Ignore("reason")] | (reason is required) |
| TUnit | [Skip("reason")] | (reason is required) |
| Conditional | #if false / #if NEVER | (no reason possible) |
Exception Handling — Idiomatic Alternatives
When a test uses try/catch to verify exceptions, suggest the framework-native alternative:
MSTest:
// Instead of try/catch (matches exact type):
var ex = Assert.ThrowsExactly<InvalidOperationException>(
() => processor.ProcessOrder(emptyOrder));
Assert.AreEqual("Order must contain at least one item", ex.Message);
// Or (also matches derived types):
var ex = Assert.Throws<InvalidOperationException>(
() => processor.ProcessOrder(emptyOrder));
Assert.AreEqual("Order must contain at least one item", ex.Message);xUnit:
var ex = Assert.Throws<InvalidOperationException>(
() => processor.ProcessOrder(emptyOrder));
Assert.Equal("Order must contain at least one item", ex.Message);NUnit:
var ex = Assert.Throws<InvalidOperationException>(
() => processor.ProcessOrder(emptyOrder));
Assert.That(ex.Message, Is.EqualTo("Order must contain at least one item"));Mystery Guest — Common .NET Patterns
| Smell indicator | What to look for |
| File system | File.ReadAllText, File.Exists, File.WriteAllBytes, Directory.GetFiles, Path.Combine with hard-coded paths |
| Database | SqlConnection, DbContext (without in-memory provider), SqlCommand |
| Network | HttpClient without HttpMessageHandler override, WebRequest, TcpClient |
| Environment | Environment.GetEnvironmentVariable, Environment.CurrentDirectory |
| Acceptable | MemoryStream, StringReader, InMemory database providers, custom DelegatingHandler |
Integration Test Markers
Recognize these as integration tests (adjust smell severity accordingly):
- Class name contains
Integration,E2E,EndToEnd, orAcceptance [TestCategory("Integration")](MSTest)[Trait("Category", "Integration")](xUnit)[Category("Integration")](NUnit)- Project name ending in
.IntegrationTestsor.E2ETests
Setup/Teardown Methods
| Framework | Setup | Teardown |
| MSTest | [TestInitialize] or constructor | [TestCleanup] or IDisposable.Dispose / IAsyncDisposable.DisposeAsync |
| xUnit | constructor | IDisposable.Dispose / IAsyncDisposable.DisposeAsync |
| NUnit | [SetUp] | [TearDown] |
| MSTest (class) | [ClassInitialize] | [ClassCleanup] |
| NUnit (class) | [OneTimeSetUp] | [OneTimeTearDown] |
| xUnit (class) | IClassFixture<T> | fixture's Dispose |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

